Guide · Open source
How to use Composer: install, declare and manage PHP dependencies
Updated · written with AI from the project's own documentation and checked against our catalogue data
Composer is an open-source dependency manager for PHP projects. It lets you declare the outside libraries, called packages, that your project needs, then installs and manages them for you. This guide explains what Composer does, what it needs on your machine, and how it fits into a typical PHP project so you can start using it with confidence.
Quick start
- 1Check your PHP version. Confirm you run PHP 7.2.5 or above for the latest Composer, or use the 2.2 LTS line for PHP 5.3.2 through 8.1.
- 2Install the binary dependencies. Make sure unzip (or 7z/7zz) and git are available on your system.
- 3Install Composer. Follow the official instructions at getcomposer.org/download for your operating system.
- 4Read the usage docs. Open getcomposer.org/doc to learn the commands for your project.
- 5Find packages. Search Packagist.org for the libraries your project needs.
- 6Declare and install dependencies. Add the packages your project requires so Composer can fetch and manage them.
What Composer does for a PHP project
Composer helps you declare, manage, and install the dependencies of PHP projects. Instead of downloading libraries by hand and copying files around, you list what your project needs and Composer fetches those packages.
Most packages come from Packagist.org, the public package index. Packagist is the default place Composer looks for libraries.
Check the requirements before you install
The latest Composer release requires PHP 7.2.5 or above. If you run an older PHP, the project's LTS notes matter: PHP versions 5.3.2 through 8.1 are still supported by the Composer 2.2 LTS releases. When you run the installer or the self-update command, the appropriate version for your PHP should be selected automatically.
For most users, two binary dependencies are essential: unzip (or 7z/7zz) and git. If the ext-zip PHP extension is available, only git is needed, although the project does not recommend this.
- PHP 7.2.5 or above for the latest version
- unzip (or 7z/7zz) and git for most users
- Optional tools such as gzip, tar, unrar, xz, Mercurial, Fossil, Perforce and Subversion depending on your packages
Install Composer
Download and install Composer by following the official instructions on the getcomposer.org download page. The README points to that page rather than listing install commands, so use it as the authoritative source for your operating system.
Once installed, the project's usage documentation is at getcomposer.org/doc, which covers day-to-day commands.
Declare and install your dependencies
Composer works from a project description that lists the packages your code needs. You declare those packages, then let Composer fetch and install them into your project. Because the same declaration is used every time, teammates and deployment systems can reproduce the same set of dependencies.
Search for available libraries on Packagist.org. Each package you find there can be added to your project's dependency list.
- Find a package on Packagist.org
- Declare it as a dependency of your project
- Let Composer install it and manage it from there
Use Composer on a team or with private packages
Composer gives a team a shared, repeatable way to install project dependencies. Everyone works from the same declared list rather than from ad hoc downloads.
If you need private package hosting, the README points to Private Packagist at packagist.com, which is a separate commercial product and not part of Composer itself.
Get help and find answers
For support, the README points to Stack Overflow, which has a large collection of questions tagged composer-php, and to GitHub discussions on the composer/composer repository. The project also asks that participants follow its Contributor Code of Conduct.
For sensitive security issues, the README asks you to email security@packagist.org rather than opening a public issue.
What people use it for
- Starting a new PHP project with standard third-party libraries
- Giving a team one repeatable way to install project dependencies
- Maintaining an existing PHP application that already uses Composer
- Pulling public packages from Packagist.org into a PHP codebase
Frequently asked questions
Is Composer free to use?
Yes. Composer is licensed under the MIT License, which is a permissive open-source licence. The LICENSE file in the repository has the full terms.
What do I need to run Composer?
The latest version requires PHP 7.2.5 or above. For most users, unzip (or 7z/7zz) and git are the essential binary dependencies.
Which PHP versions does Composer support?
The latest release needs PHP 7.2.5 or above. PHP versions 5.3.2 through 8.1 are still supported by the Composer 2.2 LTS releases, and the installer or self-update command should pick the right version for your PHP.
Where do Composer packages come from?
Most packages come from Packagist.org, the public package index. For private package hosting, the README points to Private Packagist, a separate commercial product.
Can Composer manage languages other than PHP?
No. Composer manages only PHP packages, so it is not suited to projects written in other languages.
What are alternatives to Composer?
The README does not compare tools directly, but commonly mentioned comparable projects are Yarn, npm and Pipenv. Yarn and npm serve JavaScript projects, and Pipenv serves Python projects.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Composer is a good fit for PHP developers starting a new project, teams that want a shared way to install dependencies, and anyone maintaining an existing PHP application that uses it. If you do not write PHP, or you need private package hosting without a commercial product, look at other tools or at Private Packagist.
Install options & downloads