The Composer Dependency Manager is very helpful when you need to install PHP-related frameworks, for example PHPUnit or Behat test frameworks or Laravel PHP Framework.
What is Composer?
Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. It was developed by Nils Adermann and Jordi Boggiano. They began development in April 2011 and first released it on March 1, 2012. Composer runs through the command line and installs dependencies (e.g. libraries) for an application.
How to install Composer?
Watch Video Guide
It’s very easy and takes few steps to install Composer on your windows system.
- First you can configure the PATH environment variable for PHP to run globally. To do this, following are steps, or if you don’t want to configure or you have this all set, then you can skip this step and continue to step 2.
- Open My Computer Properties.
- Go to ‘Advanced System Settings’ and go to ‘Advanced’ tab.
- Click on ‘Environment Variables…’
- In the ‘User Variables’ find the existing variable named ‘PATH’.
- We have to insert the path of our PHP installation directory in this variable. In our case it is like C:\wamp\bin\php\php5.5.12. If the ‘PATH’ variable exists then select and edit it and if not then create one. If there is some value in the existing variable then enter semi-colon ‘;’ and your PHP directory path following it.
In existing variable: - ;C:\wamp\bin\php\php5.5.12;
In newly created variable: - C:\wamp\bin\php\php5.5.12;
- Now you have to download the php archive file, composer.phar from composer website.
- Paste the composer.phar file into your PHP installation directory where your php.exe file resides. Like if you are installing it in WAMP then you have to paste composer.phar file in
C:\wamp\bin\php\php.[you’re php version]\.
- Go to the same PHP installation directory(
C:\wamp\bin\php\php.[you’re php version]\) where you’ve just pasted the composer.phar file.
- Open windows command prompt by Shift+Right-click and run and
- Create a new composer.bat file by running the beow command alongside composer.phar.
- Run following commads:
C:\wamp\bin\php\php5.5.12>echo @php "%~dp0composer.phar" %*>composer.bat
This will create new composer.bat file into your php installation directory.
- Restart your current cmd window (windows command prompt) and test the composer installation by checking composer version.
- Run the below command to check the version
If the composer is installed correctly then the above command will return the composer version something like this: -
Composer version 1.0-dev <a585d4r8e662cdsaere8sa665ase51ecaa65e4> 2016-02-01 13:09:04
If something like above happen then great, Composer is successfully installed.