search

Home  >  Q&A  >  body text

Rewritten title: Resolving Composer error: "Your version of PHP does not meet the requirements" - Reference Upgrading PHP

<p>After upgrading PHP from 7.4 to 8.0, I ran <code>composer update</code> on an existing project and got the following error: </p> <blockquote> <ul> <li>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. </li> </ul> </blockquote> <p>What does this mean and how do I fix it? </p> <p><em> (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?") </em>< ;/p>
P粉162773626P粉162773626448 days ago565

reply all(2)I'll reply

  • P粉670838735

    P粉6708387352023-08-23 22:07:58

    If you are using PHP version 8, some plugins that are not yet supported may cause installation errors.

    composer install --ignore-platform-req=php or composer install --ignore-platform-reqs

    This option can be used to set specific requirements that composer can ignore.

    reply
    0
  • P粉289775043

    P粉2897750432023-08-23 09:22:20

    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:

    • The version constraints you specify for dependencies in composer.json
    • The version constraints specified by each package for its dependencies
    • Supported PHP versions for each package

    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 follow the 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:

    1. Look at the package mentioned in the error message (e.g. acme/some-package in the example) and install it in Packagist (or any custom package source you configured) Find it on .
    2. Check to see if there is a new version that supports your PHP version.
    3. If not, you need to find out what needs to be added to support that. This might mean checking out the project directly, running its tests and submitting a patch to mark it as compatible with the new version.
    4. If (when) support is added, you need to ensure that your composer.json and other dependent packages do not exclude that new version. For example, if you currently depend on version ^1.0 of acme/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.json to 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:

    {
        "config": {
            "platform": {
                 "php": "7.4.999"
            }
        }
    }
    

    See also "Overriding PHP base dependencies in Composer"

    reply
    0
  • Cancelreply