{"record":{"id":"be6b142abd90a9b3","repo":"composer/composer","slug":"composer-2-3-0-dropped-support-for-autoloading-on","errorCode":null,"errorMessage":"Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running {php_version}, please upgrade PHP or use Composer 2.2 LTS via \"composer self-update --2.2\". Aborting.","messagePattern":"Composer 2\\.3\\.0 dropped support for autoloading on PHP <5\\.6 and you are running (.+?), please upgrade PHP or use Composer 2\\.2 LTS via \"composer self-update --2\\.2\"\\. Aborting\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/Composer/Autoload/AutoloadGenerator.php","lineNumber":996,"sourceCode":"\n        return <<<AUTOLOAD\n<?php\n\n// autoload.php @generated by Composer\n\nif (PHP_VERSION_ID < 50600) {\n    if (!headers_sent()) {\n        header('HTTP/1.1 500 Internal Server Error');\n    }\n    \\$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via \"composer self-update --2.2\". Aborting.'.PHP_EOL;\n    if (!ini_get('display_errors')) {\n        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {\n            fwrite(STDERR, \\$err);\n        } elseif (!headers_sent()) {\n            echo \\$err;\n        }\n    }\n    throw new RuntimeException(\\$err);\n}\n\nrequire_once $vendorPathToTargetDirCode;\n\nreturn ComposerAutoloaderInit$suffix::getLoader();\n\nAUTOLOAD;\n    }\n\n    /**\n     * @param string $vendorPathCode unused in this method\n     * @param string $appBaseDirCode unused in this method\n     * @param string $prependAutoloader 'true'|'false'\n     * @return string\n     */\n    protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)\n    {\n        $file = <<<HEADER","sourceCodeStart":978,"sourceCodeEnd":1014,"githubUrl":"https://github.com/composer/composer/blob/c435d285c9120efdca35696769c72ea9fdcc0466/src/Composer/Autoload/AutoloadGenerator.php#L978-L1014","documentation":"This error is thrown by the generated vendor/autoload.php file when it is loaded on a PHP version older than 5.6. Composer 2.3.0 removed support for autoloading on PHP < 5.6, so the generator (AutoloadGenerator.php) embeds a PHP_VERSION_ID guard at the top of every generated autoload.php. When the guard trips it sends a 500 HTTP status header (for web requests), prints the error to STDERR (for CLI), and throws a RuntimeException to halt execution.","triggerScenarios":"Loading vendor/autoload.php on PHP 5.5 or earlier after dependencies were installed with Composer 2.3+. The guard at AutoloadGenerator.php:984 checks PHP_VERSION_ID < 50600 and throws at line 996. This is generated code injected into the AUTOLOAD template string, not code that runs during normal Composer operation.","commonSituations":"Deploying to a production server or CI runner that has an older PHP version than the development machine. Upgrading Composer to 2.3+ on a project still hosted on PHP 5.5. Shared hosting environments where the CLI PHP and web PHP versions differ.","solutions":["Upgrade PHP on the server running the application to 5.6 or later (7.2+ recommended for Composer 2.3).","If you cannot upgrade PHP, downgrade Composer to the 2.2 LTS line: run 'composer self-update --2.2' and reinstall dependencies.","If using CI, update the PHP version in your pipeline configuration (e.g. .github/workflows, .circleci/config.yml).","Verify the PHP version with 'php -v' on the exact environment where autoload.php is loaded (CLI vs web SAPI may differ)."],"exampleFix":"# before: running on PHP 5.5\nrequire __DIR__.'/vendor/autoload.php';\n# throws RuntimeException\n\n# after: pin Composer to 2.2 LTS\n#   composer self-update --2.2\n# then reinstall:\n#   composer install\nrequire __DIR__.'/vendor/autoload.php';","handlingStrategy":"validation","validationCode":"// Before loading autoload.php, verify the PHP version is compatible\nif (PHP_VERSION_ID < 50600) {\n    // Do not load autoload.php; fall back to Composer 2.2 or upgrade PHP\n    fwrite(STDERR, 'PHP ' . PHP_VERSION . ' is too old for this autoload. Need >= 5.6.');\n    exit(1);\n}\nrequire __DIR__ . '/vendor/autoload.php';","typeGuard":"// Check whether the running PHP satisfies the Composer 2.3 autoloader guard\nfunction phpSupportsComposer23Autoload(): bool {\n    return PHP_VERSION_ID >= 50600;\n}","tryCatchPattern":"try {\n    require __DIR__ . '/vendor/autoload.php';\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'dropped support for autoloading on PHP')) {\n        // Handle: upgrade PHP or regenerate autoload with Composer 2.2 LTS\n        fwrite(STDERR, $e->getMessage());\n        exit(1);\n    }\n    throw $e;\n}","preventionTips":["Pin the PHP version in CI to match production.","If stuck on PHP <5.6, use 'composer self-update --2.2' before running install.","Check 'php -v' in both CLI and web SAPI before deploying."],"tags":["php","autoload","version","runtime","compatibility"],"backgroundTag":null,"analyzedSha":"c435d285c9120efdca35696769c72ea9fdcc0466","analyzedAt":"2026-08-07T18:58:23.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}