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!
- Download and Setup PHP
- 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)
- Unzip the contents of the PHP .zip file into C:\Program Files\PHP
- Create C:\PHP
- 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 ]
- 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 ]
- Make a copy of C:\Program Files\PHP\php.ini-production and call it C:\Program Files\PHP\php.ini
- Make PHP Available to Windows
- Right-click on the Start button (bottom left corner) and go to “System”
- Click on “Advanced system settings”
- Click on “Environment Variables…”
- Under “System variables” scroll down and highlight the variable “Path”
- Click “Edit…”
- Click “New”
- Create a new entry “C:\Program Files\PHP”
- Click “New”
- Create a new entry “C:\PHP”
- Click “OK”
- Under “System variables”, click “New…”
- For “Variable name” put “OPENSSL_CONF”
- For “Variable value” put “C:\Program Files\PHP\extras\ssl\openssl.cnf”
- Install Visual C++ Redistributable for Visual Studio 2012 Update 4
- Use this link: https://www.microsoft.com/en-us/download/details.aspx?id=30679#
- Download a copy of “vcredist_x64.exe” (or “vcredist_x86.exe” if you’re running x86)
- Run the executable to install the missing .dll files you’ll need for Composer
- Download and Install Composer
- Simply go to http://getcomposer.org/download/ and look for the Composer-Setup.exe link
- 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.