Installation of Composer on Windows(XP, 7, 8) is easy, its only take few steps.
What is Composer? it is a dependency manager tracking local dependencies of your projects and libraries. get it here. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
I assume you have xampp installed, you can get latest version from here.
Step 1) First step is to make you enable run PHP commands on Command prompt. so let the CMD(Command prompt) know where is your php.exe exist. In my case I have xampp installed in D:/ drive. so it is D:\xampp\php. copy this path.
Next right click on My Computer, then click on Advanced System Settings, under Advance tab you will see Environment variables button. click on that a dialog box will pop up like bellow.
Edit path variable and set it to D:\xampp\php. make sure you put this at the end of path string. its actually already have few paths, which are necessary to run other commands in windows.
Now check it works? open new command prompt window and run “php -v” command, if everything goes fine it should return something like bellow.
Step 2) Open your php.ini file by locating directory ‘D:\xampp\php\’ and search for “pgsql” and Disable the extension by placing a semicolon in the beginning of the line.
also enable SSL extension by un-commenting this line. this will help in download composer setup files.
Step 3) Finally now by running following command you can download composer to your environment. locate to folder where you want to install composer. like ‘D:\xampp\php\’.
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'))";
This will download and install Composer within less than a minute.
Now you can create a composer.bat file, C:\xampp\php\composer.bat and include the following code:
php %SUBDIR%\composer.phar %*
This allows you to run the command “composer” anywhere using command prompt.
You can use composer with any project directory which is set to use composer by using Command prompt run following commands in that directory.
D:\xampp\htdocs\zend> php composer.phar self-update
D:\xampp\htdocs\zend> php composer.phar install
Let say you want to install Yii2 development version with basic application using composer.
D:\xamp\htdocs> composer create-project --prefer-dist --stability=dev yiisoft/yii
It will download yii2 development version including its dependencies. see how faster it is.
Composer saves time and making your life easier, isn’t it?