Composer says the root composer.json requires a PHP version your PHP does not satisfy
Root composer.json requires php ^8.2 but your php version (8.1.2) does not satisfy that requirement.Short answer
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer. Read the full message to see which one fails. Then upgrade the PHP that Composer uses, correct a fake config.platform entry, or ignore the requirement only as a short test.
Fix it fast
1Find out which cause you have
Ask Composer which PHP and extensions it sees, and who blocks a given PHP version.
composer show --platform composer why-not php 8.32Match what you see, then jump to its fix
- 1
The version in the message is lower than the one you installedThe PHP that runs Composer is older than the project needsFix - 2
composer show --platform shows a PHP version different from php -vconfig.platform in composer.json fakes an older PHPFix - 3
Only a one-off run is wanted, not a permanent changeYou need to test on a PHP you cannot change right nowFix
- 1
What does the error look like?
Root composer.json requires php ^8.2 but your php version (8.1.2) does not satisfy that requirement.Your requirements could not be resolved to an installable set of packages.
Cause 1 of 3
The PHP that runs Composer is older than the project needs
1Check
Laravel 12 needs PHP 8.2 or newer. The command line may run an older PHP than the one you meant to use.
php -v
which -a php2Fix
Install a supported PHP and make it the one on PATH, or call Composer with that binary explicitly.
php8.3 $(which composer) install3Verify
composer install no longer prints the requirement error.
composer installConfirmed by laravel.com
Cause 2 of 3
config.platform in composer.json fakes an older PHP
1Check
The platform option makes Composer resolve against a faked PHP and ignore the local one. An old value there keeps blocking newer packages.
grep -n -A4 '"platform"' composer.json2Fix
Set it to the PHP of your real target server, or remove it, then update the lock file.
{
"config": {
"platform": { "php": "8.3.0" }
}
}3Verify
Run composer update and check that the lock file resolves.
composer updateConfirmed by getcomposer.org
Cause 3 of 3
You need to test on a PHP you cannot change right now
1Check
Composer can ignore one platform requirement for a single command. It warns this may hide real problems in production.
composer why-not php 8.32Fix
Ignore only the php requirement, and only for this run. Do not ship the result.
composer install --ignore-platform-req=php3Verify
Run check-platform-reqs on the target server before deploying.
composer check-platform-reqsConfirmed by getcomposer.org
How do I stop it coming back?
- Pin config.platform.php to your production PHP so Composer resolves what the server can run.
- Run composer check-platform-reqs in the deploy step.
- Keep the PHP version the same on development, CI and production.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Composer reports a different PHP version than php -v on Ubuntu
You are running 8.1.2.
Composer takes its PHP version from the interpreter that runs it, unless config.platform fakes one.
3 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fix