1

I have a server where I have two versions of PHP installed (PHP-7.0 and PHP-7.1). I also have two sites one using magento2.1.5 (running PHP-7.0.18) and the other a Code Ignitor project(running PHP-7.1.6).
We all know magento2.1.5 is not compatible with PHP-7.1.6. I am compiling Magento projects using this and it works fine.
Now I need to use Composer, each time i run composer install it shows the following error:

Problem 1
- magento/composer 1.0.3 requires php ~5.5.0|~5.6.0|~7.0.0 -> your PHP version (7.1.6) does not satisfy that requirement.
- magento/composer 1.0.3 requires php ~5.5.0|~5.6.0|~7.0.0 -> your PHP version (7.1.6) does not satisfy that requirement.
- Installation request for magento/composer 1.0.3 -> satisfiable by magento/composer[1.0.3].

Any solution would be appreciated...

2

You can tell composer to ignore the platform requirements by adding the --ignore-platform-reqs parameter in composer install, composer update etc.

Or you can specify the used production version in your projects composer.json with the "platform" parameter:

"config": {
  "platform": {
    "php": "7.0.18"
  }
}

This way you also ensure that composer update only installs packages that are compatible with PHP 7.0

  • does this create any side-effects later – Krishna Chalise Jun 30 '17 at 13:17
  • @Wildfire it's possible that composer installs packages that require php 7.1 when running composer update with that parameter. To avoid this, use platform (see updated answer) – Fabian Schmengler Jun 30 '17 at 13:18
0

Could you please check in composer.json for below line

"require": {
        "php": "~5.5.0|~5.6.0|~7.0.0"

Change the above line to

"require": {
        "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0"

Then run the composer install.

I hope it will works... Try it..

  • 1
    theres no such line in my composer.json – Krishna Chalise Jun 30 '17 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.