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?

We can install Composer dependency manager in windows using composer installer or using command-line.

Let's have a look on both of the methods.

First of all download the latest version of Composer-Setup.exe

Once the download is done, click the .exe file and run the setup and follow the setup guide.

Install composer dependency manager in Windows

Finish the installation and all done! Good news - this will also add Composer to your PATH variable. 

 

Watch video guide to install composer in Windows

 

It’s very easy and takes few steps to install Composer on your windows system.

    1. First, we need to 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 next step.

      1. Open My Computer Properties.
      2. Go to ‘Advanced System Settings’ and go to ‘Advanced’ tab.
      3. Click on ‘Environment Variables…’
      4. In the ‘User Variables’ find the existing variable named ‘PATH’.
      5. 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.
        For example:
          In existing variable: - ;C:\wamp\bin\php\php5.5.12;
          In newly created variable: - C:\wamp\bin\php\php5.5.12;
         
    2. Now you have to download the php archive file, composer.phar from composer website.
    3. 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.[your php version]\.
    4. Go to the same PHP installation directory(C:\wamp\bin\php\php.[your php version]\) where you’ve just pasted the composer.phar file.
    5. Open windows command prompt by Shift+Right-click and create a new composer.bat file by running the below command

                    C:\wamp\bin\php\php5.5.12>echo @php "%~dp0composer.phar" %*>composer.bat

              This will create new composer.bat file into your PHP installation 

    6. Restart your current cmd window (windows command prompt) and test the composer installation by checking composer version.
    7. Run the below command to check the version

              C:\wamp\bin\php\php.[your php version]>composer –V

If the composer is installed correctly then the above command will return the composer version something like this: -

C:\wamp\bin\php\php.[your php version]>composer –V
Composer version 1.0-dev <a585d4r8e662cdsaere8sa665ase51ecaa65e4> 2016-02-01 13:09:04

If something like above happens then great, Composer is successfully installed.