1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Using Composer 2 over SSH on your hosting
This guide explains how to run the open source dependency manager Composer 2 using an SSH command.
Preamble
- Composer is an open-source dependency manager for PHP that allows you to define, install, and update the libraries required for a PHP project.
- Composer 1 has been obsolete since 2021 and will no longer allow the installation of new packages or updates since 2025.
- Only version 2 of Composer is now supported and available on all PHP versions from 7.2 to 8.3.
Run Composer 2
Composer 2 is already pre-installed and accessible via SSH. Therefore, there is no need to install it manually.
Simple usage
Log in to your hosting via SSH, then use the following command:
composer
This command will automatically run version 2 of Composer, which is compatible with the PHP version currently in use in your session.
Check the active version
You can check the available version of Composer with:
composer --version
Example output: Composer version 2.5.0 2022-12-20 10:44:08
Force a specific PHP version
If you want to run Composer with a specific version of PHP, aliases are available. For example:
composer_php8.1 --version
or for example:
composer_php7.4
These aliases allow you to run Composer 2 with the specified PHP interpreter, useful for testing or deploying a project on a target version of PHP.