{"record":{"id":"372b81658bc72f1f","repo":"symfony/http-kernel","slug":"composer-autoloader-not-found","errorCode":null,"errorMessage":"Composer autoloader not found.","messagePattern":"Composer autoloader not found\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"HttpKernelBrowser.php","lineNumber":111,"sourceCode":"    {\n        $kernel = var_export(serialize($this->kernel), true);\n        $request = var_export(serialize($request), true);\n\n        $errorReporting = error_reporting();\n\n        $requires = '';\n        foreach (get_declared_classes() as $class) {\n            if (str_starts_with($class, 'ComposerAutoloaderInit')) {\n                $r = new \\ReflectionClass($class);\n                $file = \\dirname($r->getFileName(), 2).'/autoload.php';\n                if (file_exists($file)) {\n                    $requires .= 'require_once '.var_export($file, true).\";\\n\";\n                }\n            }\n        }\n\n        if (!$requires) {\n            throw new \\RuntimeException('Composer autoloader not found.');\n        }\n\n        $code = <<<EOF\n            <?php\n\n            error_reporting($errorReporting);\n\n            $requires\n\n            \\$kernel = unserialize($kernel);\n            \\$request = unserialize($request);\n            EOF;\n\n        return $code.$this->getHandleScript();\n    }\n\n    protected function getHandleScript(): string\n    {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/HttpKernelBrowser.php#L93-L129","documentation":"HttpCacheBrowser/HttpKernelBrowser::getScript() generates a standalone PHP script that executes the kernel in an isolated process, and it embeds the composer autoloader path. If it cannot locate any autoloader file to require, this RuntimeException is thrown because the generated script could not bootstrap.","triggerScenarios":"Running getScript()/the isolated-process test client when the script-generator cannot find a composer autoload file (no vendor/autoload.php discoverable, e.g. vendor directory moved, running outside a composer project, or unusual autoload locations).","commonSituations":"Test suite executed from a different working directory or container image where vendor/ is not in the expected location; projects using non-composer autoloading; broken vendor directory after a failed install.","solutions":["Run composer install so vendor/autoload.php exists at the expected location","Ensure tests run from the project root where vendor/ is present","If the autoloader lives elsewhere, check how the client locates it and configure accordingly or subclass to inject the path"],"exampleFix":"// in CI container before running tests\ncomposer install   # ensures vendor/autoload.php exists\nvendor/bin/phpunit","handlingStrategy":"validation","validationCode":"$autoloaders = array_filter(array_merge([\n    __DIR__.'/../vendor/autoload.php',\n    __DIR__.'/vendor/autoload.php',\n], spl_autoload_functions() ? [] : []), 'file_exists');\nif (!$autoloaders) {\n    throw new \\RuntimeException('vendor/autoload.php not found; run composer install');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $client->getScript($meta);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'autoloader')) {\n        exec('composer install');\n    }\n}","preventionTips":["Always run composer install before the test suite (esp. in CI/containers)","Run tests from the project root","Verify vendor/ is not excluded from the build image"],"tags":["testing","autoloader","symfony"],"backgroundTag":"file-not-found","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}