Install Composer

In this tutorial, we will show you how to install Composer on Windows, Ubuntu, Linux and Mac Os.

Composer is a dependency management tool in PHP that allows you to manage libraries your projects are dependent on by installing and updating them for you.

Composer is not a package manager such as Yum or Apt. However, it manages packages or libraries on a per-project basis by installing any dependencies in a directory (example vendor) inside your project. By default, Composer does not install any dependencies globally but for convenience it supports a global project via the global command.

Installing Composer on Windows

Download Composer.exe and run. It will install the latest version of Composer. After installation, you should setup your PATH so that you can call the composer command from any directory via the command line.

Installing Composer on Ubuntu / Linux / Mac

To install Composer to the current directory, run the following script in your terminal.

php -r "copy('', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

The above script will download the installer to the current directory, verify the installer SHA-384, run the installer and remove the installer.

The above script will also download the latest composer.phar in your current directory. You can move the composer.phar in a directory that is part of your PATH so that to make it accessible globally.

mv composer.phar /usr/local/bin/composer

Check which composer version is installed on your computer using the command below:

composer --version

To see the installation process in detail, go to the official site of Composer .