Thursday, 31 January 2019

Installing PHP 7 and Composer on Windows 10, Natively


I am working a lot on Composer-based Drupal projects lately (especially gearing up for DrupalCon Nashville and my joint workshop on Drupal and Composer with Matthew Grasmick), and have been trying to come up with the simplest solutions that work across macOS, Linux, and Windows. For macOS and Linux, getting PHP and Composer installed is fairly quick and easy. However, on Windows there seem to crop up little issues here and there.
Since I finally spent a little time getting the official version of PHP for native Windows installed, I figured I'd document the process here. Note that many parts of this process were learned from the concise article Install PHP7 and Composer on Windows 10 from the website KIZU 514.

Install PHP 7 on Windows 10

PHP 7 running in Windows 10 in PowerShell
  1. Install the Visual C++ Redistributable for Visual Studio 2015—this is linked in the sidebar of the PHP for Windows Download page, but it's kind of hidden. If you don't do this, you'll run into a rather cryptic error message, VCRUNTIME140.DLL was not found, and php commands won't work.
  2. Download PHP for Windows. I prefer to use 7.1.x (current release - 1), so I downloaded the latest Non-thread-safe 64-bit version of 7.1.x. I downloaded the .zip file version of the VC14 x64 Non Thread Safe edition, under the PHP 7.1 heading.
  3. Expand the zip file into the path C:\PHP7.
  4. Configure PHP to run correctly on your system:
    1. In the C:\PHP7 folder, rename the file php.ini-development to php.ini.
    2. Edit the php.ini file in a text editor (e.g. Notepad++, Atom, or Sublime Text).
    3. Change the following settings in the file and save the file:
      1. Change memory_limit from 128M to 1G (because Composer can use lots of memory!)
      2. Uncomment the line that reads ; extension_dir = "ext" (remove the ; so the line is just extension_dir = "ext").
      3. In the section where there are a bunch of extension= lines, uncomment the following lines:
        1. extension=php_gd2.dll
        2. extension=php_curl.dll
        3. extension=php_mbstring.dll
        4. extension=php_openssl.dll
        5. extension=php_pdo_mysql.dll
        6. extension=php_pdo_sqlite.dll
        7. extension=php_sockets.dll
  5. Add C:\PHP7 to your Windows system path:
    1. Open the System Control Panel.
    2. Click 'Advanced System Settings'.
    3. Click the 'Environment Variables...' button.
    4. Click on the Path row under 'System variables', and click 'Edit...'
    5. Click 'New' and add the row C:\PHP7.
    6. Click OK, then OK, then OK, and close out of the System Control Panel.
  6. Open PowerShell or another terminal emulator (I generally prefer cmder), and type in php -v to verify PHP is working.
At this point, you should see output like:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\jgeerling> php -v
PHP 7.0.29 (cli) (built: Mar 27 2018 15:23:04) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
This means PHP is working, yay!

Install Composer on Windows 10

Composer running in Windows 10 in PowerShell
Next, we're going to install Composer by downloading it and moving it into place so we can run it with just the composercommand:
  1. Download the Windows Installer for Composer and run it.
  2. Note that the Windows Installer for Composer might ask to make changes to your php.ini file. That's okay; allow it and continue through the setup wizard.
  3. Close out of any open PowerShell or other terminal windows, and then open a new one.
  4. Run the composer command, and verify you get a listing of the Composer help and available commands.
That's it! Now you have PHP 7 and Composer running natively on your Windows 10 PC. Next up, dominate the world with some new PHP projects!

Wednesday, 30 January 2019

Windows Version Numbers

Operating SystemVersion / BuildDate
Windows 95 OEM Service Release 1 (95A)4.00.950 A *)
Windows 95 OEM Service Release 2 (95B)4.00.1111 B *)
Windows 95 OEM Service Release 2.14.03.1212-1214 B *)
Windows 95 OEM Service Release 2.5 C4.03.1214 C *)
Windows 984.10.1998
Windows 98 Second Edition (SE)4.10.2222 A
Windows Millenium Beta4.90.2476
Windows Millenium4.90.3000
Windows NT 3.13.10.52827.07.1993
Windows NT 3.53.50.80721.09.1994
Windows NT 3.513.51.105730.05.1995
Windows NT 4.004.00.138124.08.1996
Windows NT 5.00 (Beta 2)5.00.1515
Windows 2000 (Beta 3)5.00.2031
Windows 2000 (Beta 3 RC2)5.00.2128
Windows 2000 (Beta 3)5.00.2183
Windows 20005.00.219517.02.2000
Whistler Server Preview2250
Whistler Server alpha2257
Whistler Server interim release2267
Whistler Server interim release2410
Windows XP (RC 1)5.1.2505
Windows XP5.1.260025.10.2001
Windows XP, Service Pack 15.1.2600.1105-1106
Windows XP, Service Pack 25.1.2600.2180
Windows XP, Service Pack 35.1.260021.04.2008
Windows .NET Server interim5.2.3541
Windows .NET Server Beta 35.2.3590
Windows .NET Server Release Candidate 1 (RC1)5.2.3660
Windows .NET Server 2003 RC25.2.3718
Windows Server 2003 (Beta?)5.2.3763
Windows Server 20035.2.379024.04.2003
Windows Server 2003, Service Pack 15.2.3790.1180
Windows Server 20035.2.3790.1218
Windows Home Server5.2.379016.06.2007
Windows Longhorn6.0.5048
Windows Vista, Beta 16.0.511220.07.2005
Windows Vista, Community Technology Preview (CTP)6.0.521930.08.2005
Windows Vista, TAP Preview6.0.525917.11.2005
Windows Vista, CTP (Dezember)6.0.527014.12.2005
Windows Vista, CTP (Februar)6.0.530817.02.2006
Windows Vista, CTP (Refresh)6.0.534221.03.2006
Windows Vista, April EWD6.0.536519.04.2006
Windows Vista, Beta 2 Previw6.0.538101.05.2006
Windows Vista, Beta 26.0.538418.05.2006
Windows Vista, Pre-RC16.0.545620.06.2006
Windows Vista, Pre-RC1, Build 54726.0.547213.07.2006
Windows Vista, Pre-RC1, Build 55366.0.553621.08.2006
Windows Vista, RC16.0.5600.1638429.08.2006
Windows Vista, Pre-RC26.0.570010.08.2006
Windows Vista, Pre-RC2, Build 57286.0.572817.09.2006
Windows Vista, RC26.0.5744.1638403.10.2006
Windows Vista, Pre-RTM, Build 58086.0.580812.10.2006
Windows Vista, Pre-RTM, Build 58246.0.582417.10.2006
Windows Vista, Pre-RTM, Build 58406.0.584018.10.2006
Windows Vista, RTM (Release to Manufacturing)6.0.6000.1638601.11.2006
Windows Vista6.0.600008.11.2006
Windows Vista, Service Pack 26.0.600204.02.2008
Windows Server 20086.0.600127.02.2008
Windows 7, RTM (Release to Manufacturing)6.1.7600.1638522.10.2009
Windows 76.1.760022.10.2009
Windows 7, Service Pack 16.1.7601
Windows Server 2008 R2, RTM (Release to Manufacturing)6.1.7600.1638522.10.2009
Windows Server 2008 R2, SP16.1.7601
Windows Home Server 20116.1.840005.04.2011
Windows Server 20126.2.920004.09.2012
Windows 86.2.920026.10.2012
Windows Phone 86.2.1021129.10.2012
Windows Server 2012 R26.3.920018.10.2013
Windows 8.16.3.920017.10.2013
Windows 8.1, Update 16.3.960008.04.2014
Windows 10 (1507)10.0.1024029.07.2015
Windows 10 (1511)10.0.1058610.11.2015
Windows 10 (1607)10.0.1439302.08.2016
Windows Server 2016, RTM (Release to Manufacturing)10.0.1439326.09.2016
Windows 10 (1703)10.0.1506305.04.2017
Windows 10 (1709)10.0.1629917.10.2017
Windows 10 (1803)10.0.1713430.04.2018
Windows 10 (1809)10.0.1776302.10.2018