phpsymfony

How to get all loaded classes during the response generation?


I've used autoload but it's not giving all the files/classes that's been used during request

spl_autoload_register(function ($class) {
    $logFile = __DIR__ . '/autoload_log.txt';
    $message = $class . "\n";
    file_put_contents($logFile, $message, FILE_APPEND);
}, true, true);

Is there any other way to trace all classes that's been involved during the page generation for Symfony project?


Solution

  • Getting declared classes was the only valuable solution:

    $loadedClasses = get_declared_classes();
    sort($loadedClasses);
    $logFile = __DIR__ . '/autoload_log_declared.txt';
    $logContent = implode("\n", $loadedClasses);
    file_put_contents($logFile, $logContent, FILE_APPEND);