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:
- Create a sensible directory which you would like PHP to live. (I like
- 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.
- Extract the archive to the directory you created in part one.
- Uncomment the
php-production.inifile and open it in your favourite editor.
- Find the line:
;extension=php_openssl.dlland change it to
extension=php_openssl.dll. (Note the removal of the ;)
- Save the file and rename it to php.ini.
Once PHP has been installed, head over to the Composer website and download the Windows Installer named
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.