Composer can be installed on Windows, Linux, Unix, and OS X. For this example, we will be following the install found at https://getcomposer.org/download/. Ensure that you take a look at the Getting Started documentation that corresponds with your operating system.
Begin by opening a new Terminal window. By default, our Terminal window should place us in the user directory. We can then continue by executing the following four commands:
- Download Composer installer to the local directory:
php -r "copy('https://getcomposer.org/installer', 'composer-
setup.php');"
- Verify the installer:
Since Composer versions are often updated, it is important to refer to the date on the Download Composer page to ensure that the preceding hash file is the most current one.
- Run the installer:
php composer-setup.php
- Remove the installer:
php -r "unlink('composer-setup.php');"
- Composer is now installed locally, and we can verify this by executing the following command within a Terminal window:
php composer.phar
- Composer should now present us with a list of the available commands:

The challenge with having Composer installed locally is that it restricts us from using it outside the current user directory. In most cases, we will be creating projects outside of our user directory, so having the ability to globally use Composer quickly becomes a necessity.