How to Install and Use Composer or PHP Dependency Manager » How to Install and Use Composer or PHP Dependency Manager

How to Install and Use Composer or PHP Dependency Manager

This entry is part 1 of 7 in the series PHP Advance Tutorial

In this guide, we will install Composer or PHP Dependency Manager in the window through the CMD (command line Manger) PHP on Windows 10. Also, you can use this guideline on any of the window operating system (window-XP,window7,window8,window10).

Composer is a PHP dependency manager that is used to install the PHP Libraries. You can find all the PHP packages list here.

Step1. Setup Localhost

Install the localhost on your computer. To make the localhost you can use any of the third-party localhost provider link xampp, wamp, lamp.

Run your localhost 

Step2. Download the composer 

You can install the composer by two way 

  • Download composer.exe file and run with  administrator
  • You can also install the composer by cmd 
php -r "copy('', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { echo 'Installer verified'; } else { echo 'Installer corrupt';
unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Composer Installed

Step3. Now we have to use Composer

Your composer has been successfully installed you can check it by past this command in cmd


Now switch to your localhost root directory 

Make a directory into the root folder

mkdir test

Now change the directory to test and install the package that you want. Here we will install the php timer package for demo

composer require phpunit/php-timer
php timer library demo code for composer

Now make a php file demo.php 

And past this code and hit the file in chrome

require __DIR__ . '/vendor/autoload.php';
use SebastianBergmann\Timer\Timer;
$timer = new Timer;
foreach (\range(0, 100000) as $i) {
    // ...
$duration = $timer-&gt;stop();

Thank You! Your composer has been successfully installed and Used.

Series NavigationHow to call soap API in PHP and Postman soap >>
Join the discussion

Translate »
Share via
Copy link