Tlanyan. me/windows-com…
The preparatory work
- Github.com/Microsoft/p… Download phP-SDK (Clone or Download on the right and select download Zip below);
- 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.
- Visualstudio.microsoft.com/zh-hans/dow… Select visual studio community 2017 and select C++ features during installation.
compile
- Create a new compile directory, for example “D:\PHP2Compile”;
- Decompress the “php-sdK-binary-tools-master. zip” file to the compile directory.
- Hold down Shift, right-click in the compile directory, and select “Open Powershell Window Here”;
- Run “phpsdk-vc15-x64.bat”, and the prompt will change from “>” to “$”.
- 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”.
- Create a php-src folder under the “phpdev/vc15/x64” directory and copy the PHP source code to this directory.
- Switch to php-src (CD php-src) and run “phpsdk_deps -u”;
- Set up pecl directory under “phpdev/vc15/x64” (same as PHP source directory) and copy the expansion to this directory;
- Execute “buildconf” in the PHP source directory;
- 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 “;
- 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
- 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.
- Bat “could not determine ‘vc15’ directory” “Could not determine ‘vc15’ directory”
- Unneeded extensions can be deleted before compilation to speed up compilation;
- If a custom extension appears “cannot open include file ‘win95nt.h'”, use this header: github.com/nonylene/is… .
reference
- Wiki.php.net/internals/w…
- Blog.51cto.com/lancelot/20…