composer/composer · critical · RuntimeException
Composer 2.3.0 dropped support for autoloading on PHP <5.6…
Error message
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. What it means
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.
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).
Example fix
# before: running on PHP 5.5 require __DIR__.'/vendor/autoload.php'; # throws RuntimeException # after: pin Composer to 2.2 LTS # composer self-update --2.2 # then reinstall: # composer install require __DIR__.'/vendor/autoload.php';
Defensive patterns
Strategy: validation
Validate before calling
// Before loading autoload.php, verify the PHP version is compatible
if (PHP_VERSION_ID < 50600) {
// Do not load autoload.php; fall back to Composer 2.2 or upgrade PHP
fwrite(STDERR, 'PHP ' . PHP_VERSION . ' is too old for this autoload. Need >= 5.6.');
exit(1);
}
require __DIR__ . '/vendor/autoload.php'; Type guard
// Check whether the running PHP satisfies the Composer 2.3 autoloader guard
function phpSupportsComposer23Autoload(): bool {
return PHP_VERSION_ID >= 50600;
} Try / catch
try {
require __DIR__ . '/vendor/autoload.php';
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'dropped support for autoloading on PHP')) {
// Handle: upgrade PHP or regenerate autoload with Composer 2.2 LTS
fwrite(STDERR, $e->getMessage());
exit(1);
}
throw $e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Composer detected issues in your platform
- A non-empty PSR-4 prefix must end with a namespace…
- At least the plugin package should always be autoloaded for…
- Can't run git rev-list. You must ensure to run compile from…
- Failed getting info from curl handle
AI-assisted analysis of composer/composer@c435d285c9 (2026-08-07).
Data as JSON: /api/errors/be6b142abd90a9b3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Composer/Autoload/AutoloadGenerator.php:996
return <<<AUTOLOAD
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
\$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;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, \$err);
} elseif (!headers_sent()) {
echo \$err;
}
}
throw new RuntimeException(\$err);
}
require_once $vendorPathToTargetDirCode;
return ComposerAutoloaderInit$suffix::getLoader();
AUTOLOAD;
}
/**
* @param string $vendorPathCode unused in this method
* @param string $appBaseDirCode unused in this method
* @param string $prependAutoloader 'true'|'false'
* @return string
*/
protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)
{
$file = <<<HEADERView on GitHub (pinned to c435d285c9)