If you are on windows, the easiest way to install composer is by grabbing a copy of windows installer provided by the official composer website. The instruction are outlined below. Make sure you already have PHP installed in your system. It comes bundled with XAMPP, WAMP or otherwise you can install independently by downloading the package from http://windows.php.net/download/. Once you got PHP running, you have to know where php.exe is located before proceeding with the composer installation.
Here are the steps you should follow:
- Visit https://getcomposer.org/download/
- Download the Composer-Setup.exe to your computer
- Run setup and follow its instructions to install composer
- Once the installer is finished, open up a command prompt and try running below command:
If composer has been installed properly, it should display the current version information. See below screenshot:
Next lets see how to get composer running on a Linux environment. Similar to Windows, it is assumed that you have a working PHP installation resides on your system and it is accessible in your PATH.
- Open up a new shell
- Execute below command to download composer.phar to your current working directory:
$ curl -s https://getcomposer.org/installer | php
- Once that command completes, you can execute below command which will move the downloaded composer.phar file from your current directory to /usr/local/bin directory and rename it to ‘composer’. /usr/local/bin directory is already in your system path so this step will ensure that you will be able to execute composer commands from anywhere in your file system:
sudo mv composer.phar /usr/local/bin/composer
Now its time to verify the installation. Open another shell window and enter below command:
If it display the version information, our installation has been successful and now you should be able to use composer with your projects.