Install and Use Composer on Your Hosting Account
Updated 4 weeks ago
Composer, the PHP dependency manager, is installed and used from the command line on your hosting account, either with cPanel’s Terminal tool or via SSH. Composer installs the libraries your project needs in a vendor folder within the project itself.
This procedure installs Composer only for your hosting account user, without requiring administrator permissions.
Before you begin
You need command-line access to your account: cPanel’s Terminal tool or an SSH client such as Putty. The SSH access port is 4444. If you have any questions, follow the guide How to access via SSH.
The latest version of Composer requires PHP 7.2.5 or later. You can check or change your account’s PHP version by following the guide Change PHP version and settings.
Download and install Composer
We install Composer by downloading its official installer and running it with PHP:
In Terminal, navigate to the /tmp directory:
cd /tmpDownload and run the official Composer installer:
curl -sS https://getcomposer.org/installer | phpThe installer checks your PHP configuration and downloads the composer.phar file, which is the Composer executable.
Make the composer command available
We move composer.phar to a folder in your user’s PATH and add it to your shell configuration:
We create the ~/bin folder and move the executable there, renaming it composer:
mkdir ~/bin mv composer.phar ~/bin/composer chmod +x ~/bin/composerWe add the folder to the PATH and reload the configuration:
echo "export PATH=$HOME/bin:$PATH" >> ~/.bash_profile source ~/.bash_profile
Verify the installation
Check that the command is available and see which version was installed:
Check the executable path:
which composerIt should return ~/bin/composer.
Check the version:
composer --version
Install packages with Composer
Find the package you need on Packagist, the official PHP package repository, and install it with composer require from your project folder. For example, to install Bootstrap:
composer require twbs/bootstrapComposer downloads the package and its dependencies and puts them in the project’s vendor folder.