Composer is PHP's dependency manager, maintained by the open-source Composer community. It ties for #26 in usage among developer tools, showing up in roughly 11% of surveyed projects. It's the standard way modern PHP projects โ Laravel, Symfony, and countless WordPress plugins โ declare their library dependencies and pull them straight from Packagist, PHP's central package registry.
Composer tracks your project's dependencies in a composer.json file, which you can edit by hand or update via the CLI.
# add a real HTTP client library to the project
composer require guzzlehttp/guzzle
// resulting composer.json
{
"require": {
"php": "^8.2",
"guzzlehttp/guzzle": "^7.8"
},
"autoload": {
"psr-4": { "App\\": "src/" }
}
}
Install Composer globally via its installer script, then run it from any PHP project directory.
# download and install Composer globally (Linux/macOS)
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# install all dependencies listed in composer.json
composer install