Note: It will be better to do it with VS2015!
Pre-development preparation work:
Cygwin
Visual Studio 2012
PHP post-compilation program
The XAMPP integrated installation package is used, so the compiled program path is D:\xampp\php
PHP before compiling the source code
The PHP-5.6.14-SRC is used, the path is D:\HACFIN\CODE\PHP\PHP_SDK_WIN\PHP-5.6.14-SRC
1. Modify "ext_skel_win32.php" file
D:\Hacfin\Code\PHP\php_sdk_win\php-5.6.14-src\ext\ext_skel_win32.php, modify the Cygwin path.
$cygwin _path = ' c:\cygwin64\bin '; Change the $cygwin_path to the path where you actually installed the Cygwin.
2. Build PHP Extension Development framework
In the source code ext directory, which is D:\Hacfin\Code\PHP\php_sdk_win\php-5.6.14-src\ext, run cmd. Execute PHP ext_skel_win32.php--extname=<ext_name>, this will be generated in the EXT directory <EXT_NAME> directory, this directory is the framework for PHP extension development. For example, if you run Php.exe ext_skel_win32.php--extname=twig, the twig directory will be generated in the Ext directory, where the twig represents your PHP extension.
3. Copy link library
Copy the D:\xampp\php\dev\php5ts.lib to "ext/<ext_name>". For example, if you want to develop PHP extension twig, then you need to copy the Php5ts.lib to the PHP source file directory \ext\twig.
Note: If the php5ts.lib (if the non-thread-safe version is the name Php5.lib) is 64-bit, then VS2012 's solution platform is set to X64 and cannot be set to Win32. The platform solution is aligned with the number of bits in the PHP core library. Otherwise, errors will occur,
4. Add "config.w32.h" file
Search for "Config.w32.h" in the PHP source code file directory and find "Config.w32.h.in" in the D:\Hacfin\Code\PHP\php_sdk_win\php-5.6.14-src\win32\build folder. , copy the file into the E:\php-5.6.9-src\main folder and remove the ". In" from the back.
Note: In order for the extension to match the PHP Runtime environment strictly, depending on the compiled version of your PHP runtime (php5.6.14 is VC11 compiled), add the following in the Config.w32.h file:
#define PHP_COMPILER_ID "VC11"
5. Cancel the predefined macro "Libzend_exports" (otherwise Zend function cannot be introduced)
Go to <EXT_NAME> directory and open <EXT_NAME>.DSP.
VS2012 Compiling PHP extensions