How to Install and Use Composer on Windows – a Complete Guide

Installing composer is quick and easy, however, for some people, this process is quite troublesome, therefore, today we’ll discuss how to install composer on windows, in addition, we’ll also discuss how to use the Composer on Windows.


  1. How to Install Composer on Windows
  2. How to Use Composer on Windows
  3. Solve an Error: PHP Startup: Unable to load dynamic library
  4. How to Change The PHP Version

I. How to Install Composer on Windows

Installing composer can be done with a few easy steps:

1 Download the installer file

Download the installer file by accessing the direct download link:, or visiting the official download page:

2 Run the installer file

Next, run the installer file

Important: During the installation process, we need to connect to the Internet, because the installer will download composer and some of necessary components.

Step 1 First, a setup window will appear tell us that the installer will download and setup composer, just click Next >.

Composer Setup Window

Step 2 Next, specify the location of the PHP file (php.exe file) that will be used on the command line along with composer itself.

This file is usually located in the PHP directory. If you use XAMPP, for example: installed in E:\xampp, then the location is in the E:\xampp\php directory, so the result become E:\xampp\php\php.exe as follow:

How to Install Composer on Windows - Specify PHP File Location

Then, Click Next > to continue

Furthermore, Composer will test whether PHP can do the job.

NOTE: If an error occurred, please read the solution in the section: III. How to Solve Error When Installing Composer: “PHP Startup: Unable to load dynamic library”

Step 3 Next, specify whether yo need to use a proxy. If you use a proxy, then check the option “Use a proxy server to connect to the Internet” and write the proxy address and its port, for example:

Setting a Proxy Server

Click Next > to continue

Step 4 Next the window will display the resume of the settings, click “Install” to continue.

Review Settings

Step 5 The installer will download Composer and related components and then install it on the computer.

The Setup is Downloading and Installing The Composer

Step 6 There is a notice tell us that there is a change in the Windows Environment, this means that now the composer can run on a command prompt.

Changes in Enviranment Variables

There are two variables added to the system environment:

  • In the “User variables” section: PATH variable with a value of the location of composer’s binary file (C:\Users\agusph\AppData\Roaming\Composer\vendor\bin)
  • “System Variables” section: PATH variable with the value of the location of php.exe file (E:\xampp\php)

The Environment Variables

Step 7 The installation processes have completed, click Finish to close the installation window.

How to Install Composer on Windows - Finish

Step 8 Next, test whether the composer can run properly. Open a command prompt and run the command: composer --version, if successful, the version of composer will be shown:

Test Whether The Composer is Successfully Installed

Done. Next, will discuss how to use composer in windows

II. How to Use Composer in Windows

After successfully installing composer on windows, the next problem for new users is how to use it, especially defining the directory, well, here we will discuss how to do it.

Composer works on the directory where the command prompt run, for example, when we want to install or update a package in the directory of “E:\xampp\htdocs\Minify\src” then we have to point the cursor to that directory.

The following example will install PHP Minify package that is used to compress javascript files using PHP:

  1. Open a command prompt and navigate the cursor to a directory where we will install the package, e.g: E:\xampp-7.0.6\htdocs\Minify\src
  2. Next, run the command composer require matthiasmullie/minify. The command usually provided by the author. In this example, we can find the command on the front page of PHP Minify package.

    Wait until the process complete (sometimes takes a long time)

    How to Use Composer on Windows

  3. To ensure that the installation process is successful, open the folder where we have installed the package.

    Package Installation Was Successfull

How to Use Composer Behind a Proxy

If we use the internet connection behind a proxy, then we have to make adjustments to the command prompt.

To do so, before using the composer, run the command (for HTTP) set http_proxy:proxy_name:port_number and set https_proxy:proxy_name:port_number for https, for example: set https_proxy:

How to Use Composer Behind a Proxy


III. How to Solve an Error When Installing Composer on Windows: PHP Startup: Unable to load dynamic library

Sometimes the composer installation processes do not run smoothly (an error occurred), typically the error message is “PHP Startup: Unable to load dynamic library …”

Error - PHP Startup Unable To Load Dynamic Library

This error occurs when the installer does some test running the PHP, but PHP can not load the necessary modules. Those modules are listed in the PHP configuration file (php.ini)

To overcome this, do the following steps:

  1. Open the php.ini file, usually located in the PHP folder, if you use xampp then this file is in the “xampp\php” folder.
  2. Next, search (CTRL + F) a word of extension_dir, then look at the value, it is usually a relative path, eg “\xampp\php\ext”, then change it to absolute path, eg “E:\xampp\php\ext”

    Change Relative Path into Absolute Path

  3. Next, again, use (CTRL + F) to search the rest of the relative path and change it to the absolute path.
  4. Save the file and restart the installation process

Done. you should now not encounter such problem again.

IV. How to Change the PHP Command Line Path In Composer

After successfully installing the composer, later we may want to update our PHP software to the new version and we want to adjust it to our composer.

To update PHP used by the composer, we only need to change the environment path, to do so:

  1. Open Windows Environment: right-click on My Computer and select Properties. Then, select Advanced system settings and click the “Environment Variables” button

    Windows Environment

  2. In the “System variables” section, select the “Path” variable and click edit. Search PHP path we used in our composer, and then change it to our new php.exe file, for example, the previous is “E:\xampp\php” then I change to “E:\xampp-7\php”

    How to Change PHP Version Used by Composer

    Click OK to save the changes

  3. Test it by running the command composer --version, if successful the version of the composer will appear.
  4. However, if there is an error message, usually: “PHP Startup: Unable to load dynamic library …”, then repeat the previous section III. How to Solve an Error When Installing Composer in Windows: “PHP Startup: Unable to load dynamic library”

Subscibe Now

Loves articles on join our newsletter to get quality article right to your inbox. Nothing else, just quality stuff!!!

Our Commitment: We respect your privacy, we'll not share your credential to any party

29 Responses

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Like Us


Great information from right to your inbox

  1. Understanding JSONP – With Javascript and jQuery Examples

  2. JSON With Javascript and Ajax

  3. JSON From Database – PHP and MySQL

  4. JSON in HTML Document

  5. JSON With PHP – A Complete Guide

  6. Understanding JSON – A Comprehensive Guide

  7. 7 Best Free Online Image Compressor & Optimizer Tools – Compared & Tested

  8. 40+ Modern Free WordPress Themes For Blog in 2017 – Beautiful & Responsive

  9. Understanding Constant in PHP – Updated to PHP 7

  10. Understanding Variable in PHP – All PHP Version