composer/composer · critical · RuntimeException
Composer 2.3.0 dropped support for autoloading on PHP <5.6 a
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 is generated source code: AutoloadGenerator writes this RuntimeException into vendor/autoload.php, and it is thrown at runtime when that generated autoloader is required on a PHP version below 5.6. Composer 2.3.0+ relies on PHP 5.6+ language features, so the generated autoloader refuses to run on older runtimes and sends a 500 header if in a web context.
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 6ffc117740)
Solutions
- Upgrade the runtime PHP to 5.6 or newer (recommended).
- Downgrade Composer to 2.2 LTS on the build machine with `composer self-update --2.2` so the generated autoloader stays 5.x compatible.
- Align build and production PHP versions so the generated autoloader targets a supported runtime.
Example fix
// before (build with Composer 2.3, deploy to PHP 5.5) composer install # generates autoloader requiring PHP >= 5.6 // after composer self-update --2.2 composer install # generates a 5.x-compatible autoloader
Defensive patterns
Strategy: fallback
Validate before calling
if (PHP_VERSION_ID < 50600) { throw new \RuntimeException('PHP < 5.6 is unsupported by this autoloader; use Composer 2.2 LTS to generate it.'); } Type guard
function autoloadCompatiblePhp(): bool { return PHP_VERSION_ID >= 50600; } Try / catch
try { require __DIR__ . '/vendor/autoload.php'; } catch (\RuntimeException $e) { http_response_code(500); error_log($e->getMessage()); // fall back to 2.2-generated autoloader or upgrade PHP exit(1); } Prevention
- Keep build and production PHP versions aligned.
- If production must stay on PHP 5.5, generate the autoloader with Composer 2.2 LTS (`composer self-update --2.2`).
- Add a deployment smoke-test that requires the generated autoloader on the target PHP.
When it happens
Trigger: Deploying an application whose dependencies were installed with Composer 2.3+ onto a server running PHP 5.5 or earlier, then including vendor/autoload.php. The throw occurs in the generated autoloader, not in the Composer binary.
Common situations: Legacy hosting with old PHP; CI/build image using a newer PHP than the production runtime; CI installing with Composer 2.3 but deploying to a PHP 5.5 box.
Related errors
- There is no version of Composer available for your PHP versi
- Cannot use table format with {io_class}
- Invalid format "{format}".
- Not enough arguments (missing: "packages").
- Composer update failed: the "{localFilename}" is not accessi
AI-assisted analysis of composer/composer@6ffc117740 (2026-08-07).
Data as JSON: /api/errors/be6b142abd90a9b3.
Report an issue: GitHub.