How to compile PHP 7 for Magento 2 on Windows

Step 1

Install .NET Framework 4.6.

Step 2

Install Visual Studio 2015 Community Edition.

Step 3

Create a folder for the PHP 7 compilation.
It is E:\work\sandbox\php7 in my case.

Step 4

Download the latest Binary Tools and extract it to the PHP 7 compilation folder (E:\work\sandbox\php7 in my case.).

Step 5

Open «All Programs» → «Visual Studio 2015» → «Visual Studio Tools» → «Windows Desktop Command Prompts» → «VS2015 x64 Native Tools Command Prompt»:

Step 6

cd E:\work\sandbox\php7
bin\phpsdk_buildtree.bat dev

The dev folder will be created:

Step 7

cd dev
xcopy vc9 vc14 /E /I /H /R /K /Y
cd vc14\x64

Step 8

Download the source code for the latest PHP 7 release.
You can do at the

You can also do it on GitHub:

Step 9

Extract the archive to the E:\work\sandbox\php7\dev\vc14\x64 folder:

If you downloaded the arhive from GitHub then you should adjust the extracted folder name to the php-7.0.1-src format.

Step 10

Download the archive of libraries required for the PHP 7 compilation (deps-7.0-vc14-x64.7z):

Extract the archive to the E:\work\sandbox\php7\dev\vc14\x64 folder:

Step 11

cd "E:\work\sandbox\php7"
cd "dev\vc14\x64\php-7.0.1-src"

Step 12


Step 13

mkdir ..\obj

Step 14

configure ^
  --enable-object-out-dir=../obj/ ^
  --enable-debug-pack ^
  --enable-apache2-4handler ^
  --with-curl=static ^
  --with-mhash=static ^
  --enable-intl ^
  --enable-mbstring ^
  --enable-mbregex ^
  --with-mcrypt=static ^
  --with-openssl=static ^
  --with-pgsql ^
  --with-config-file-scan-dir=C:/server/php/ini ^
  --enable-exif ^
  --enable-pdo ^
  --with-pdo-mysql ^
  --enable-soap ^
  --with-xmlrpc=static ^

Step 15


Step 16

Copy the compilation results to the PHP destination folder.

Step 17

Load PHP module with Apache:

LoadModule php7_module "C:/server/php/php7apache2_4.dll"