🔍 Introduction
If you manage PHP projects on a cPanel server, you may have noticed that Composer, the PHP dependency manager, is not installed by default. This guide shows you how to check if it’s installed, install it locally, and use it effectively.
🧰 What is Composer?
Composer is a dependency management tool for PHP. It allows you to:
- Automatically install the libraries required for your projects.
- Easily manage package updates.
- Ensure compatibility between different PHP versions and packages.
🧪 Check if Composer is Installed on cPanel
Connect via SSH and type:
which composerResult:
- ✅ If installed: shows the path (e.g.,
/home/youruser/composer) - ❌ If empty: Composer needs to be installed manually
🛠️ Install Composer Locally on cPanel
- Navigate to your home directory:
cd /home/youruser - Download the installation script:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - Install Composer:
php composer-setup.php --install-dir=/home/youruser --filename=composer - Remove the script:
php -r "unlink('composer-setup.php');" - Verify the installation:
/home/youruser/composer --version
🔗 Add Composer to the PATH
Current session:
export PATH=/home/youruser:$PATHPermanent:
- Edit the
.bashrcfile:nano ~/.bashrc - Add at the end:
export PATH=/home/youruser:$PATH - Reload the file:
source ~/.bashrc
🚀 Use Composer in Your PHP Projects
- Install dependencies:
cd ~/my-project composer install - Update packages:
composer update
📘 Conclusion
Installing Composer on cPanel is simple and does not require root access. Once installed locally and added to your PATH, you can manage PHP dependencies as if Composer were installed globally.
For more information, see the official Composer documentation.


