Installing Composer on Windows 10

Sheldon P.
9-composer.jpg

Preface

First off, I have had a very long night. I had to get Composer installed on my computer in order to complete a mandate for a client and I ran into more stumbling blocks than I care to admit. In the end, though, I managed to learn a lot about how to install Composer on a Windows 10 machine and was able to perform a second install on my office desktop in about ten minutes.

The purpose of my writing this blog entry is to (hopefully) help any of you out there who have run into the same problem.

 

What Is Composer and Why Should I Care?

These are good questions. In fact, these are questions that, until recently, I was asking myself. I don’t have an answer yet, but these are good questions to ask … I guess …

 

The Good Stuff

Ok, so how exactly do you install Composer on Windows? What’s the big deal? If you’re reading this, very likely, you’ve already tried it yourself and run into stumbling blocks and got stuck. The reason it took me so long last night is because I had to try a bunch of things that ended up being dead-ends. The list of steps below is the boiled down version of what I managed to figure out through much trial and error. These are also the only steps I took in order to install Composer on my second machine this morning. Best of luck!

  1. Download and Setup PHP
    1. Download PHP for Windows – Go to http://windows.php.net/download/ and grab a “Thread Safe” version. I used PHP 5.5.31 VC11 x64 Thread Safe (since I needed 5.5 for my project and I am running on a x64 machine)
    2. Unzip the contents of the PHP .zip file into C:\Program Files\PHP
    3. Create C:\PHP
    4. Copy the file C:\Program Files\PHP\ext\php_openssl.dll to C:\PHP [ I reran these instructions with PHP7.1 and noticed that I need to place files under C:\PHP\ext now ]
    5. Edit the files C:\Program Files\PHP\php.ini-development and C:\Program Files\PHP\php.ini-production in a text editor (like Notepad) and remove the semicolon (;) from line 876 (it should be extension=php_openssl.dll) [ thanks to La_Basse_Cour_BnB for pointing out that in later versions of PHP, the line number is now 907 ]
    6. Make a copy of C:\Program Files\PHP\php.ini-production and call it C:\Program Files\PHP\php.ini
  2. Make PHP Available to Windows
    1. Right-click on the Start button (bottom left corner) and go to “System”
    2. Click on “Advanced system settings”
    3. Click on “Environment Variables…”
    4. Under “System variables” scroll down and highlight the variable “Path”
    5. Click “Edit…”
    6. Click “New”
    7. Create a new entry “C:\Program Files\PHP”
    8. Click “New”
    9. Create a new entry “C:\PHP”
    10. Click “OK”
    11. Under “System variables”, click “New…”
    12. For “Variable name” put “OPENSSL_CONF”
    13. For “Variable value” put “C:\Program Files\PHP\extras\ssl\openssl.cnf”
  3. Install Visual C++ Redistributable for Visual Studio 2012 Update 4
    1. Use this link: https://www.microsoft.com/en-us/download/details.aspx?id=30679#
    2. Download a copy of “vcredist_x64.exe” (or “vcredist_x86.exe” if you’re running x86)
    3. Run the executable to install the missing .dll files you’ll need for Composer
  4. Download and Install Composer
    1. Simply go to http://getcomposer.org/download/ and look for the Composer-Setup.exe link
    2. Install Composer

If you did all of the steps before the final one of installing Composer, you should be in good shape. Composer needs to be able to find PHP and OpenSSL and also needs the missing DLLs that Visual C++ Redistributable installs.

I hope this helps you save a few hours of searching the web.