Home > Software engineering >  Cant run composer install because a mismatch in PHP version
Cant run composer install because a mismatch in PHP version

Time:05-23

I have PHP version 8.1.5 as I'm writing this and I'm trying to experiment with older github repo like trix tutorial for example and a problem occurs when I tried to run composer install an error that said

    Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - Root composer.json requires php ^7.2.5 but your php version (8.1.5) does not satisfy that requirement.
  Problem 2
    - doctrine/inflector is locked to version 1.3.1 and an update of this package was not requested.
    - doctrine/inflector 1.3.1 requires php ^7.1 -> your php version (8.1.5) does not satisfy that requirement.
  Problem 3
    - doctrine/lexer is locked to version 1.2.0 and an update of this package was not requested.
    - doctrine/lexer 1.2.0 requires php ^7.2 -> your php version (8.1.5) does not satisfy that requirement.
  Problem 4
    - dragonmantank/cron-expression is locked to version v2.3.0 and an update of this package was not requested.
    - dragonmantank/cron-expression v2.3.0 requires php ^7.0 -> your php version (8.1.5) does not satisfy that requirement.
  Problem 5
    - laravel/framework is locked to version v7.2.1 and an update of this package was not requested.
    - laravel/framework v7.2.1 requires php ^7.2.5 -> your php version (8.1.5) does not satisfy that requirement.
...

I certainly don't want to downgrade my PHP version is there a way to upgrade those packages to be compatible with my PHP version?

so far I've tried

change my composer.json file

"require": {
        "php": ">=8.1.5",
        ...
    },

and

"require": {
        "php": ">=7.2.5",
        ...
    },

and running both composer install and composer update php --with-all-dependencies

CodePudding user response:

if you are using on local just install the php 8 version then run composer install

CodePudding user response:

You can also use Composer's --ignore-platform-reqs switch to install packages. It will install packages without complaining, but it's not guaranteed that your code will run.

  • Related