2

I know many people are struggling into the "composer using the wrong php version" and the solution is to call composer with the good one (currently suggested duplicate).

Here is my case:

$ php -v
PHP 5.6.31 (cli) (built: Sep  8 2017 04:36:13) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

$ php /usr/local/bin/composer update
  Problem 1
    - This package requires php >=5.6.31 but your PHP version (5.5.9)
      does not satisfy that requirement.

How can this be explained ?


For info, I'm using the official php:5.6-fpm docker image. And I installed composer with:

$ curl -sS https://getcomposer.org/installer
  | php -- --install-dir=/usr/local/bin --filename=composer
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • Sounds like you have your web server using one instance of php, and maybe have a different php in your $PATH, that composer is seeing........? – Stuart Sep 08 '17 at 09:43
  • Possible duplicate of [composer to use newer version of php](https://stackoverflow.com/questions/15673334/composer-to-use-newer-version-of-php) – Calimero Sep 08 '17 at 09:48
  • You could run composer with `--ignore-platform-reqs` to ignore the PHP version, but be aware that this could cause you problems in the long run, e.g. when trying to run the code in the wrong PHP version as well. – dbrumann Sep 08 '17 at 09:49
  • Has the possible duplicate helped solve the question? If so, I will close it. Otherwise, please respond to other comments Pierre and for the possible duplicate not solving it, thank you. – Funk Forty Niner Sep 08 '17 at 10:20
  • The suggested duplicate is what I'm talking about in my first sentence, but maybe [this other one](https://stackoverflow.com/questions/32838881/) can help, I'll check that as soon as I have the time (Related to @dbrumann suggestion) – Pierre de LESPINAY Sep 08 '17 at 10:45
  • 1
    can you check in your composer.json? there might be a php version overwrite (symfony skeleton does this for example) see https://getcomposer.org/doc/06-config.md#platform this could also be set in your users config – Norman M Sep 08 '17 at 11:17
  • That was it ! I just realized that before seing your comment – Pierre de LESPINAY Sep 08 '17 at 11:25

1 Answers1

8

I just realized this config at the bottom of my composer.json:

"config": {
    "platform": {
        "php": "5.5.9"
    }
},

That's the version on which it bases his warning (not the one actually used)

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • You can change this using `composer config platform.php 5.6`. – deltab Oct 06 '17 at 12:54
  • the greatness of this is, so many Composer looking at wrong php versions exist on SO and this needs to be linked to it! Now I have an answer in my dupe arsenal to use! – treyBake Apr 01 '19 at 10:01