Tlanyan. me/windows-com…

The preparatory work

  1. Github.com/Microsoft/p… Download phP-SDK (Clone or Download on the right and select download Zip below);
  2. Windows.php.net/downloads/r… Download the source code for PHP7.2, the latest version is 7.2.8, and select php-7.2.8-src.zip to download it.
  3. Visualstudio.microsoft.com/zh-hans/dow… Select visual studio community 2017 and select C++ features during installation.

compile

  1. Create a new compile directory, for example “D:\PHP2Compile”;
  2. Decompress the “php-sdK-binary-tools-master. zip” file to the compile directory.
  3. Hold down Shift, right-click in the compile directory, and select “Open Powershell Window Here”;
  4. Run “phpsdk-vc15-x64.bat”, and the prompt will change from “>” to “$”.
  5. Run “phpsdk_buildtree phpdev” to add a “phpdev “directory to the successful directory, and the command line directory will automatically switch to “phpdev/vc15/x64”.
  6. Create a php-src folder under the “phpdev/vc15/x64” directory and copy the PHP source code to this directory.
  7. Switch to php-src (CD php-src) and run “phpsdk_deps -u”;
  8. Set up pecl directory under “phpdev/vc15/x64” (same as PHP source directory) and copy the expansion to this directory;
  9. Execute “buildconf” in the PHP source directory;
  10. Run the “configure — some options” command to configure the compilation options, For example, “configure –disable-all –enable-cli –enable-cgi –enable-zlib –enable-hash –enable-session –without-gd – with -.bz2 – enable – yourext “;
  11. Execute nmake command to compile PHP and extend.

After a successful compilation, a “Release “or “Release_TS” directory will be generated in the X64 directory of the source code, where the compiled php.exe and the generated extended DLL are located. DLL file name, for example, php_tlanyan.dll.

NTS and TS

The default compiled extension is the TS (thread-safe) version (located in the Release_TS directory). If you want to build a non-thread-safe version, add the “–disable-zts” option to configure.

Thread-safe version (php.exe -v output) :

PHP 7.2.8 (cli) (built: Aug 14 2018 10:53:41) (Visual C++ 2017) x64) Copyright (C) 1997-2018 The PHP Group Zend Engine V3.2.0, Copyright (c) 1998-2018 Zend TechnologiesCopy the code

Non-thread-safe version output:

PHP 7.2.8 (cli) (built: Aug 14 2018 11:47:40) (NTS MSVC15 (Visual C++ 2017) x64) Copyright (C) 1997-2018 The PHP Group Zend Engine V3.2.0, Copyright (c) 1998-2018 Zend TechnologiesCopy the code

Matters needing attention

  1. The original PHP – windows.php.net/downloads/p SDK download address… Only SDK tools of PHP7.1 and earlier can be downloaded. For PHP7.2 tools, download them from Github.
  2. Bat “could not determine ‘vc15’ directory” “Could not determine ‘vc15’ directory”
  3. Unneeded extensions can be deleted before compilation to speed up compilation;
  4. If a custom extension appears “cannot open include file ‘win95nt.h'”, use this header: github.com/nonylene/is… .

reference

  1. Wiki.php.net/internals/w…
  2. Blog.51cto.com/lancelot/20…