This article describes how to develop php extensions in Windows 7. For more information, see
1. first view the phpinfo () information
PHP Version 5.4.34
Zend Extension Build API220100525, TS, VC9
PHP Extension Build API20100525, TS, VC9
Thread Safety enable
Thread security, VC9 compilation, version 5.4.34
2. preparations before development
Php 5.3-5.4: Visual C ++ 9.0 (Visual Studio 2008)
Install Cygwin (: http://www.cygwin.com/), virtual linux environment
Php compiled program and pre-compiled source code (: http://windows.php.net/download)
The compiled program path: php-5.4.45-Win32-VC9-x86 \
Source code path before compilation: php-5.4.45-src \
Download php sdk, http://windows.php.net/downloads/php-sdk/
1. decompress the php-sdk-binary-tools-20151115.zipfile to add the system path to the bin directory of bison.exe.Medium
Copy php-5.4.45-Win32-VC9-x86 \ dev \ php5ts. lib to php-5.4.45-src \ Release_TS \ php5ts. lib
Create a php-5.4.45-src \ main \ config. 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-src \ ext \ ext_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 toassociate it with a program. chooses the CLI version of php.*/$cygwin_path = 'D:\Program Files\cygwin\bin';
Change it to your cygwin installation directory.
3, run cmd, enter the php source code directory, php-5.4.45-src \ ext, run the command php ext_skel_win32.php -- extname = myphpexs
Remember to add the directory of php.exe to path, -- extname = your extension name,
If successful, the myphpexs folder will be generated in the ext Directory. the content is as follows:
4. use vs2008 to open myphpexs. dsp, change the solution configuration to Release, and run the generated command.
If it succeeds, the php_myphpexs.dll file will be generated. my php_myphpexs.dll will be generated again in the Release_TS folder of the php source code root directory.
5. put php_myphpexs.dll to your php extension directory, and then add extension = php_myphpexs.dll to php. ini.
6. create the php script file test. php. the content is as follows:
The code is as follows:
Echo confirm_myphpexs_compiled ('test ');
7. run the test file and the following content is displayed.
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 number function for creating extensions. you can delete and modify functions when editing your own extensions.