Tell Composer to use Different PHP Version

Solution 1:

Ubuntu 18.04 case ... this run for me.

/usr/bin/php7.1 /usr/local/bin/composer update

Solution 2:

Maybe this can't solve exactly your issue but probably it will help others who comes here from web search.

Just add below code to your composer.json file to set different php version:

"config": {
    "platform": {
        "php": "7.1.3"
    }
}

Solution 3:

On xubuntu I had php 7.2 as default. But needed to run composer with php 5.6.

So this worked for me:

php5.6 /usr/bin/composer

Solution 4:

If you just need to get composer to ignore the version requirements, you can bypass using:

composer install --ignore-platform-reqs