Using Composer on StackCP requires specifying the full path to the PHP version you want to use. This guide will show you how to run Composer commands via SSH on your StackCP hosting.
Understanding PHP Versions on StackCP #
At StackCP, multiple versions of PHP are available. By default, the system-level PHP used for internal tools might not include all the modules you’re familiar with. Therefore, specifying the path to the desired PHP version is necessary.
Running Composer with Specific PHP Versions #
Here’s how to use different PHP versions to execute Composer commands:
- Log in to SSH:
- Use your SSH credentials to log in to your StackCP account.
- Check Available PHP Versions:
- Upon logging in, the message of the day (MOTD) will display the available PHP versions. Note the version you want to use.
- Run Composer Command:
- To use PHP 7.1, for example, you would use the following command:
/usr/bin/php71 -f /usr/bin/composer install
- This specifies that PHP 7.1 should be used to execute the Composer script.
Using Composer 2.0 #
Composer 2.0 is available on StackCP. To use Composer 2.0, invoke composer2 instead of composer:
/usr/local/bin/composer2 install
This ensures you’re using the updated version of Composer for your dependencies.
Summary #
By following these steps, you can run Composer commands via SSH on your StackCP hosting using the PHP version of your choice.