Composer Dependency Manager
PHP Composer
Composer is a dependency-management tool for PHP projects. It reads project requirements from composer.json, downloads the required packages, and generates an autoloader for use by the application.
Composer Overview
vendor/autoload.php for loading installed classes.Check the current stack first
Certified PHP nodes may already include Composer. Connect to the node and run composer --version before installing another copy.
Install Composer through SSH
Prepare SSH access
Generate an SSH key pair, add the public key to the dashboard, and connect to the Apache PHP or NGINX PHP node through the platform SSH gateway.
Download the Composer installer
Run the installer from the server working directory:
curl -sS https://getcomposer.org/installer | php
Move Composer to a private bin directory
Create the user-level binary directory and rename composer.phar to composer.
mkdir -p ~/bin mv composer.phar ~/bin/composer chmod +x ~/bin/composer
Installer verification
For production use, verify the Composer installer signature according to the current official Composer installation instructions before executing it.
Add Composer to PATH
Add the private binary directory to the shell PATH so Composer can be executed from any project directory.
Apache PHP
export PATH=$PATH:/var/www/bin echo 'export PATH=$PATH:/var/www/bin' >> ~/.bashrc source ~/.bashrc
NGINX PHP
export PATH=$PATH:/var/lib/nginx/bin echo 'export PATH=$PATH:/var/lib/nginx/bin' >> ~/.bashrc source ~/.bashrc
Depending on the node template, the actual home and private bin path may differ. Use the directory where composer was placed.
Verify Composer
Confirm that Composer is available:
composer about composer --version
Manage Project Dependencies
Open the deployed project directory before running Composer commands. A typical application root is under /var/www/webroot/ROOT, although the exact path depends on the stack and deployment mode.
Install Locked Dependencies
cd /var/www/webroot/ROOT composer install
For a production deployment, a common command is:
composer install --no-dev --optimize-autoloader
Add a Package
composer require vendor/package
Update Dependencies
composer update
Use update carefully
composer update recalculates dependency versions and rewrites composer.lock. For predictable production deployment, commit a tested lock file and use composer install.
Review Installed Packages
composer show composer diagnose
Expected Result
Composer is available on the PHP node and can be executed from the project directory to install, update, inspect, and autoload the dependencies declared by the application.
Important Notes
- Check whether Composer is already installed before adding another copy.
- Verify that the project’s required PHP version and extensions are available.
- Run Composer as the application user rather than as root whenever possible.
- Commit
composer.jsonandcomposer.lockto version control. - Avoid committing the generated
vendordirectory unless the deployment process requires it. - Run dependency installation on every node or include it in a repeatable deployment workflow for horizontally scaled environments.
Common Issues and Solutions
php.ini and restart the PHP node.composer.lock file and run the same install command on every application node.