1. First check the phpinfo() information
PHP Version 5.4.34
Zend Extension Build API220100525,TS,VC9
PHP Extension Build API20100525,TS,VC9
Thread Safety enable
Thread safe, VC9 compiled, version 5.4.34
2. Preparation work before development
php 5.3-5.4: Visual C 9.0 (Visual Studio 2008)
Install Cygwin (download address: http://www.cygwin.com/), virtual linux environment
PHP compiled program and source code before compilation (download address: http://windows.php.net/download/)
Compiled program path: php-5.4.45-Win32-VC9-x86
Source code path before compilation: php-5.4.45-src
Download the php sdk file, http://windows.php.net/downloads/php-sdk/
1. Unzip the files in php-sdk-binary-tools-20110915.zip and add the bin directory where bison.exe is located to the system path
Copy php-5.4.45-Win32-VC9-x86devphp5ts.lib to php-5.4.45-srcRelease_TSphp5ts.lib
Create a new php-5.4.45-srcmainconfig.win32.h with the following content:
#define SIZEOF_LONG 4
#define PHP_COMPILER_ID "VC9"
"VC9" corresponds to VC9
2. Find the php source code directory, php-5.4.45-srcextext_skel_win32.php
/* This script can be used on Win systems ) Make sure you have CygWin installed ) Adjust the $cygwin_path to match your installation ) Change the environment cariable PATHEXT to include .PHP ) run ext_skel --extname=... the first time you run this script you will be asked to associate it with a program. chooses the CLI version of php. */ $cygwin_path = 'D:\Program Files\cygwin\bin';
Change this to your cygwin installation directory.
3. Run cmd, enter the php source code directory, php-5.4.45-srcext, and run the command php ext_skel_win32.php --extname=myphpexs
Remember to add the directory where php.exe is located to path, --extname=your extension name,
If successful, the myphpexs folder will be generated in the ext directory with the following content
4. Open myphpexs.dsp with vs2008, change the solution configuration to Release, and execute the generation command
If everything goes well, the php_myphpexs.dll file will be generated. I generated php_myphpexs.dll in the Release_TS folder of the php source code root directory
5. Place php_myphpexs.dll in your php extension directory, and add extension=php_myphpexs.dll to php.ini
6. Create a new php script file test.php with the following content
Copy code The code is as follows:
echo confirm_myphpexs_compiled('test');
7. Run the test file and the following content will appear. Success
Copy code The code is as follows:
Congratulations! You have successfully modified ext/myphpext/config.m4. Module 23 is now compiled into PHP.
8. confirm_myphpexs_compiled is a built-in volume function when creating an extension. When editing your own extension content, you can delete the modified function