Composer is a fantastic dependency manager for PHP. If you are using Windows, there is an installer available that does most of the legwork for you. There are some pre-requisites, however, and if you are running into trouble with the installation process the following steps should — hopefully — help towards achieving a successful install.

Getting PHP and Enabling OpenSSL

Composer works with most versions of PHP and simply requires openssl to be enabled. The steps to install PHP and enable openssl are as follows:

  1. Create a sensible directory which you would like PHP to live. (I like C:\PHP).
  2. Download the zip of the latest stable release of the version of PHP you want from the PHP website making sure the machine architecture is correct for your hardware.
  3. Extract the archive to the directory you created in part one.
  4. Uncomment the php-production.ini file and open it in your favourite editor.
  5. Find the line: ;extension=php_openssl.dll and change it to extension=php_openssl.dll. (Note the removal of the ;)
  6. Save the file and rename it to php.ini.

Getting Composer

Once PHP has been installed, head over to the Composer website and download the Windows Installer named Composer-Setup.exe.

Before running the installer, make sure .BAT is added to your PATHEXT. It should be by default, however if you’ve changed your environment variables, it may no longer be.

Run through the installer and make sure to select the correct path to PHP that you created above. It usually does a good job of finding it automatically, but just make sure to either select the correct path or that path it found is correct.

It’ll let you know of any issues or failed pre-requisites. Installing other extensions should be identical to openssl, just with a different name.

Once all pre-requisited have been met, the installer should take care of the rest.

Once complete, open your favourite shell and type the command composer -V, you should see a response of something along the lines of:

Composer version 1.0-dev (hashwillgohere)

That tells us that composer has been installed successfully.

To learn more about how to use Composer, check out the documentation.