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

Dependency managementInstalls and updates the PHP packages declared by the project.
composer.jsonStores the project dependency requirements and Composer configuration.
composer.lockRecords the exact installed package versions for repeatable deployments.
AutoloadingGenerates vendor/autoload.php for loading installed classes.
i

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

1

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.

2

Download the Composer installer

Run the installer from the server working directory:

curl -sS https://getcomposer.org/installer | php
3

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.

4

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.json and composer.lock to version control.
  • Avoid committing the generated vendor directory 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

composer command is not foundCheck the private bin path, shell profile, file name, and executable permission.
PHP extension requirement failsEnable the required extension in php.ini and restart the PHP node.
Permission denied in vendorRun Composer as the correct application user and review project-directory ownership.
Memory limit is exceededReview PHP CLI memory settings and the dependency graph before increasing the limit.
Packages differ between nodesUse the same composer.lock file and run the same install command on every application node.