run composer with php 7.1 instead of php 5.6

Avatar
  • Answered
Recently we upgrade to the next version of laravel framework, this new versions required php 7.+, we already switch to this php version through cpanel, but the sorprice was when try to run composer command. it comes predefined to use php 5.6 cli.
when i try to deply the proyect, composer gives me a error about php version.
So i need some help to change de default path of php version to run composer, i make and alias to force console commands to run php 7.1, and it work well with custom scripts, but not with composer.

I hope you can help me, thanks for your time
Avatar
-1
KyleM
Hello, Thanks for contacting us about changing the PHP version composer is using, You can try changing the default version of PHP on your server from the WHM as root if you have root access to the server which should cause it to use that version. If you do not have root access you could try and prefix the command with the PHP version you would like to use, The default for PHP 7.1 on EasyApache 4 should be /opt/cpanel/ea-php71/root/usr/bin/php. If that will not work for what you are running you can trick composer into thinking its on the correct version of PHP by editing your composer.json file and adding the entry below with your desired PHP version.
"config": {
    "platform": {
        "php": "7.1.3"
    }
}
Best Regards, Kyle M