Installing Composer on windows

1 . Go to the website https://getcomposer.org

2 . Download the window installer i.e. “Composer-Setup.exe”. When you click on this file after downloaded, you will see the following dialog box.

Installing Composer

3 . Then press the next button and you will land to the following state. Here, you have to select the php.exe file which will be used by composer. This php.exe file could be found in the wamp or xampp installation folder. In my case, it is located at the path D:\xampp\php\php.exe

Composer Installing

Following window will be displayed after this step.

Installing composer

Installing Composer

Press on the install button and composer will start to install.

Installing Composer

Installing Composer

Installing Composer

Now you are done and composer has been installed to your Windows system.

Test if composer has been installed Properly.

1 . To verify the composer installation, we will use it for demo purpose. Let’s create the test folder in system anywhere as following. And create the file “composer.json” which will be used by composer tool.

Composer Demo

2.   Suppose you want to use the monolog library in your project to send your logs to files, email, web services etc. So, we need to install this library in our project. 

3.    Go to the website https://packagist.org, this website manages PHP package Repository. Here you could search for the term “monolog” and you will see it in search result. See the following screenshot: 

composer demo monolog

4.    Write the following text in the composer.json file.

{
    "require": {
        "monolog/monolog": "1.0.*"
    }
}

Here, You are simply telling Composer which packages your project depends on.

5.    Run the composer command as following;

composer demo initialization

6.    After this execution, see the folder in which you are, that is test folder. You see some extra things there, As following

Composer project

This implies that the composer has been installed properly.

Tags