-2

I've tried a number of suggestions around similar questions on stackoverflow, but no success.

In summary, my project is failing due to Laravel/composer using the wrong PHP version.

Here's my setup.

  1. I've set up a subdomain to test out Laravel on a Centos VPS.
  2. I've set the PHP version for that subdomain to use PHP 8
  3. if I run /usr/local/bin/php -v, I get back that PHP 8.0.1 is installed (see attached image "1", 1st yellow arrow)
  4. if I just run php -v, again I get PHP 8.0.1 (see attached image "1", 2nd yellow arrow)
  5. when I run composer -vvv about, the feedback is that composer is using PHP 5.6.40 (see attached image red arrow "2")

I've also modified composer.config, in the directory my project is in with the following lines

"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "config": {
        "platform": {
            "php": "8.0.1"
        }
    },
    "sort-packages": true
},

so my question is where/how do I change the PHP setting composer is using.

enter image description here

suggestions are greatly appreciated, thxs!

Soccerjf
  • 65
  • 1
  • 3

1 Answers1

2

Check your where is composer path:

which composer

Usually the path is /usr/local/bin/composer , but it's seem you use composer on cPanel right? if on cPanel, the path is /opt/cpanel/composer/bin/composer and use default cpanel/whm php version. so run below command to use specific PHP version

php /opt/cpanel/composer/bin/composer -vvv about

You can use any installed PHP version example php7.4 /usr/local/bin/composer etc

on cpanel to select other php version you need prefix ea-, eg: ea-php71, ea-php56, ea-php80, etc

you can run composer command like below:

ea-php71 /opt/cpanel/composer/bin/composer install
ea-php80 /opt/cpanel/composer/bin/composer update
Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
  • Thxs for the speedy reply Muhammad. I was running ssh (terminal) via cPanel and the path was the expected "/usr/local/bin/composer". Did find the problem though, too many cooks in the kitchen, the default version for php for the vps was changed to 8.0 but no one reset the services so the old version 5.4 was the default. Reboot has now set the default in composer to the expected value of 8.0. – Soccerjf Jan 19 '21 at 22:55