Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell Composer to use Different PHP Version

I've been stuck at this for a few days. I'm using 1and1 hosting, and they have their PHP set up a bit weird.

If I use just php composer.phar install, then I'm using PHP 4.4.6, which is horribly insufficient. However, I can run php5.5 composer.phar install, get a little bit further, but it still fails because somewhere along the line, PHP is called again, but it fails, as it's using 4.4.6.

Is there any way to tell Composer to use the php5.5 command? Has anyone successfully gotten Composer configured on 1and1 hosting?

I'm trying to get Laravel up and running (which uses Composer). I've been able to do it on my GoDaddy domain, but not 1and1.

like image 927
Boom Avatar asked Sep 23 '15 22:09

Boom


People also ask

How do I use a different version of Composer?

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies. Once you have installed your dependencies, now you can run the same command and pass in --2 as the flag and this will switch back to composer version 2.

Can Composer update PHP?

It also makes maintaining the latest versions of all required libraries easier because you can simply run composer update to get the latest compatible packages.


2 Answers

Ubuntu 18.04 case ... this run for me.

/usr/bin/php7.1 /usr/local/bin/composer update 
like image 62
Florin Avatar answered Oct 05 '22 07:10

Florin


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"     } } 
like image 40
Shaig Khaligli Avatar answered Oct 05 '22 07:10

Shaig Khaligli