After upgrading PHP from 7.4 to 8.0, I ran composer update
on an existing project and got the following error:
- acme/some-package[1.0.0, ..., 1.4.0] requires php ^5.6.4 || ^7.0 -> Your php version (8.0.3) does not meet this requirement.
What does this mean and how do I fix it?
(This is a reference answer intended to cover a frequently encountered problem. The scenario is just an example. See also: "How to interpret Composer's error logs?") < ;/p>
If you are using PHP version 8, some plugins that are not yet supported may cause installation errors.
composer install --ignore-platform-req=php
orcomposer install --ignore-platform-reqs
This option can be used to set specific requirements that composer can ignore.
question
In addition to the versions of other packages they require, Composer packages can also specify the PHP versions they support.
When parsing the version of a package to install, Composer must find a version that matches all constraints:
composer.json
If there is no package that satisfies all these constraints, you will receive an error.
Common confusion
Please note that version constraints for PHP versions followthe same rules as other Composer constraints. Therefore, the constraint
^7.0
means "any 7.x version above 7.0", excluding 8.0.solution
To solve this problem, you need to relax one of the constraints:
acme/some-package
in the example) and install it inPackagist(or any custom package source you configured) Find it on .composer.json
and other dependent packages do not exclude that new version. For example, if you currently depend on version^1.0
ofacme/some-package
, but PHP 8.0 is only supported starting with version 2.2.0, you will need to change the constraint to^2.2
and make sure your application is still compatible.Temporary solution
Sometimes you are pretty sure that your application will run correctly using the same package version as before. In this case, you can use
platformconfiguration variables
in
composer.jsonto pretend you are still using the old version.This should only be used as a temporary workaround or for testing, as it means that packages may be installed that will not work at all on your new PHP version.For example:
See also "Overriding PHP base dependencies in Composer"