Tell Composer to use a different php version
I am trying to get Composer to run on a client's machine using php 8.0. I installed Composer using the following commands:
But when I check `composer diagnose` it keeps telling me that it's using php 7.2:
Is there a way on a cpanel server to have the php cli default to a higher version, without changing the default for all of the users on that server? Note that in whm php is set to 8.0 for the user in question, but that doesn't seem to have any effect on php cli. I also tried aliasing php to php 8.0 in the ~/.bashrc file, so it does show 8.0 when I type in `php -v`, but that appears to have no effect at all on what Composer sees. Thanks. -Michael PS Is the "code" button in the post editor broken for anyone else? Instead of bringing up the dialog window to insert code, it's bringing up a list of the forums on here.
curl -sS https://getcomposer.org/installer | /opt/cpanel/ea-php80/root/usr/bin/php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
But when I check `composer diagnose` it keeps telling me that it's using php 7.2:
Checking composer version: OK
Composer version: 2.5.2
PHP version: 7.2.34
PHP binary path: /opt/cpanel/ea-php72/root/usr/bin/php
OpenSSL version: OpenSSL 1.1.1s 1 Nov 2022
cURL version: 7.87.0 libz 1.2.7 ssl OpenSSL/1.1.1s
zip: extension not loaded, unzip present, 7-Zip not available
Is there a way on a cpanel server to have the php cli default to a higher version, without changing the default for all of the users on that server? Note that in whm php is set to 8.0 for the user in question, but that doesn't seem to have any effect on php cli. I also tried aliasing php to php 8.0 in the ~/.bashrc file, so it does show 8.0 when I type in `php -v`, but that appears to have no effect at all on what Composer sees. Thanks. -Michael PS Is the "code" button in the post editor broken for anyone else? Instead of bringing up the dialog window to insert code, it's bringing up a list of the forums on here.
-
Try running the composer the following way, and see if that helps: /usr/local/bin/ea-php80 /usr/local/bin/composer install
Regarding the code button, this is a known issue and cPanel team is currently working on a new forum so that would be solved soon.0 -
Try running the composer the following way, and see if that helps:
/usr/local/bin/ea-php80 /usr/local/bin/composer install
Regarding the code button, this is a known issue and cPanel team is currently working on a new forum so that would be solved soon.
I know I can use the full path to the binary with php but I was still wondering if there is a way to change which php version is accessed by default when you use the cli version. -Michael0
Please sign in to leave a comment.
Comments
3 comments