Home > Article > Backend Development > Methods to develop and compile PHP extensions under windows_PHP tutorial
Now let’s briefly talk about the steps to develop PHP extensions under WINDOWS:
The software you need to prepare first is:
cygwin installation path e:appcygwin
visual studio C++ 6.0,
Modify the environment variables and change the The installed PHP path is set as an environment variable. Here, assuming that my PHP installation directory is: e:appphp5.2.5, then I add this installation directory after the WINDOWS environment variable. It is convenient to use php.exe for a while.
PHP source code, here it is assumed to be e:c_source_codephp-5.2.5
1. Modify the file "PHP source file directory/ext/ext_skel_win32.php", here it is: E:c_source_codephp-5.2. 5ext, the main thing is to modify the cygwin path. $cygwin_path = 'e:appcygwinbin';
Change $cygwin_path to the path where you actually installed cygwin.
2. In the source code ext directory, which is e:c_source_codephp-5.2.5ext, execute php ext_skel_win32.php --extname=
3. Copy php-rootdevphp5ts.lib to "ext/
4. Modify the content of foo.c and write the C code we need.
5. Enter the
Set up the VC6 project,
Setting menu "Build"->"Remove Project Configuration", select "Win 32 Release_TS",
Setting menu "Project", select "Win 32 Release_TS"
Open Tab "Connection", set the directory in "Output File Name",
[Optional] Open Tab "C/C++", add "Preprocessor Definition" ",COMPILE_DL_
6. After setting up, compile and a dll file will be generated. The file name is
Copy foo.dll to e: appext directory, and add a line extension=foo.dll to php.ini. Restart apache and check phpinfo();. You will find that our PHP extension foo() has been loaded and you can use this foo extension.