Home  >  Article  >  Backend Development  >  Methods to develop and compile PHP extensions under windows_PHP tutorial

Methods to develop and compile PHP extensions under windows_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:31:18789browse

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=. At this time, the directory will be generated in the ext directory. This The directory is the framework in which we will develop PHP extensions. For example, if you run php.exe ext_skel_win32.php --extname=foo, the foo directory will be generated in the ext directory.
3. Copy php-rootdevphp5ts.lib to "ext/". For example, if the PHP extension you want to develop is foo, then you need to copy php-rootdevphp5ts.lib to the PHP source file directory extfoo.
4. Modify the content of foo.c and write the C code we need.
5. Enter the directory and open .dsp.
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_" (note all capital letters, (added by default), cancel the predefined "LIBZEND_EXPORTS" (otherwise the zend function cannot be introduced).
6. After setting up, compile and a dll file will be generated. The file name is .dll. For example, in our example it is foo.dll
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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323063.htmlTechArticleNow let’s briefly talk about the steps to develop PHP extensions under WINDOWS: The software that needs to be prepared first is: cygwin installation path e:appcygwin visual studio C++ 6.0, modify the environment variables and install...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn