How do I add Composer to my hosting account?
Composer is not in the $PATH on cloud web hosting servers because the Composer package is continually updated. We instead recommend installing and maintaining your own Composer version compatible with your applications and workflow.
Install Composer
Section titled “Install Composer”-
Connect to your hosting account via SSH (How do I log into SSH (shared / cloud web hosting?)
-
Create a
.local/bindirectory in your home directory if it is missing:Terminal window mkdir -p ~/.local/bin -
Navigate to the
bindirectory:Terminal window cd ~/.local/bin -
Download Composer:
Terminal window curl -s https://getcomposer.org/installer | php -- --filename=composer -
Make Composer executable:
Terminal window chmod +x composer
Verify Installation
Section titled “Verify Installation”You can verify that Composer is installed correctly by running:
composer --versionIf you get a “command not found” error, you may need to add the ~/.local/bin directory to your $PATH.
Adding your bin to $PATH
Section titled “Adding your bin to $PATH”New accounts should have the ~/.local/bin directory in their $PATH by default. Depending on the age of your account, it may be missing. You can add your bin folder to $PATH by doing the following:
Find the following line in your ~/.bashrc file:
# User specific environmentBelow it, add the following:
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]then PATH="$HOME/.local/bin:$HOME/bin:$PATH"fiexport PATHOnce added, reload your shell configuration:
source ~/.bashrcUpdating Composer
Section titled “Updating Composer”As you are managing your own Composer installation, you will need to update it manually when new versions are released. To update Composer to the latest version, run the following command:
composer self-update