Composer

term

programmingweb dev

Kept in this browser · My desk

The dependency manager for PHP: a project declares its libraries in composer.json, and Composer resolves, locks and installs them into the project's vendor directory.

It manages dependencies per project rather than system-wide, writes the exact versions to composer.lock, which its documentation says to commit so every machine installs the same code, and generates the autoloader the application includes. composer audit checks the installed packages against security advisories, abandoned packages and packages flagged as malware.

Composer resolves version constraints such as 2.0.* against repositories, Packagist by default, and treats PHP itself and its extensions as platform packages (php, ext-name) that a project can require but Composer cannot install. Its documentation names npm and Ruby's bundler as its inspiration. The current release needs PHP 7.2.5, and a long-term-support line, 2.2.x, still runs on PHP 5.3.2 and later.

For an operator it is the second update stream on a PHP server: patching the PHP runtime changes nothing in vendor/, and updating a library changes nothing in the runtime. The lock file is the inventory of that second stream.

Also known as: php composer, composer.json, composer.lock, composer audit, vendor directory

← Back to C Back to the glossary