Composer Installation
Before you can use Composer, it needs to be installed on your machine. Composer is a command-line tool,
so once installed you'll run it from your terminal (Command Prompt / PowerShell on Windows, or a shell
on Linux/macOS). This page covers installing Composer on each platform, verifying the install, the
difference between a global install and a local composer.phar file, and how
to update Composer itself later on.
Installing Composer on Windows
The easiest way to install Composer on Windows is with the official Composer-Setup.exe installer,
downloaded from getcomposer.org.
Run the installer, and it will detect your PHP installation (for example your XAMPP or WAMP
php.exe), add Composer to your system PATH, and set everything up automatically.
Once it finishes, close and reopen your terminal so it picks up the new PATH entry.
Installing Composer on Linux / macOS
On Linux and macOS, Composer is installed using an official installer script. Downloading it, then
running the downloaded PHP file, verifies it against a signature and installs Composer globally so
the composer command works from any directory.
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php composer-setup.php
$ sudo mv composer.phar /usr/local/bin/composer
$ php -r "unlink('composer-setup.php');"
The mv step moves the downloaded composer.phar file into a directory that's
already on your system PATH, so afterwards you can simply type composer from anywhere.
Verifying the Installation
Whichever platform you're on, confirm Composer is installed correctly by asking it for its version:
$ composer --version
Composer version 2.7.1 2024-02-09 15:26:28
If you see a version number printed back, Composer is installed and ready to use. If instead you get a "command not found" (or "not recognized") error, Composer either isn't installed yet or isn't on your system PATH.
Global Install vs. Local composer.phar
There are two common ways Composer ends up available to a project, and it's worth knowing the difference:
| Approach | How it's used |
|---|---|
| Global install | Composer is installed once on the machine and available everywhere as the plain composer command — this is what the installers above set up. |
Local composer.phar | A single composer.phar file sits inside one project folder. You run it directly, e.g. php composer.phar require monolog/monolog, without needing Composer on your system PATH at all. |
Most developers use a global install for convenience, and reach for a local composer.phar
only in situations like shared hosting where they can't install anything system-wide, or when a CI
pipeline wants a pinned Composer binary checked into the project.
Keeping Composer Up to Date
Composer itself gets new releases over time — bug fixes, performance improvements, and new features.
If you installed it globally, you can update the composer command in place with:
$ composer self-update
This downloads the latest Composer release and replaces your current composer.phar (or its
global equivalent) with it, so the next time you run composer --version you'll see the new
version number.