How to develop and compile PHP extensions under Windows
Source: Internet
Author: User
Now let's just say one of the steps to developing PHP extensions under Windows:
The first software that needs to be prepared is:
Cygwin installation path E:\app\cygwin
Visual Studio C + + 6.0,
Modify the environment variable to set the already installed PHP path to the environment variable. Here, assuming that my PHP installation directory is: e:\app\php5.2.5, then I put the Windows environment variables behind this installation directory. Easy to use Php.exe for a while.
PHP source code, here is assumed to be e:\c_source_code\php-5.2.5
1, modify the file "php source file directory/ext/ext_skel_win32.php", here is: E:\c_source_code\php-5.2.5\ext, which is mainly to modify the Cygwin path. $cygwin _path = ' e:\app\cygwin\bin ';
Change the $cygwin_path to the path where you actually install the Cygwin.
2, in the source code ext directory is e:\c_source_code\php-5.2.5\ext, the implementation of PHP ext_skel_win32.php--extname=<ext_name>, at this time will be generated in the EXT directory <EXT_NAME> directory, this is the framework that we will be developing for PHP expansion. 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 the Php-root\dev\php5ts.lib to "ext/<ext_name>". For example, if you are developing a php extension of Foo, then you need to copy the Php-root\dev\php5ts.lib to the PHP source directory \ext\foo.
4, modify FOO.C content, write the C code we need.
5, enter <EXT_NAME> directory, open <EXT_NAME>.DSP.
Set up the VC6 project,
Set Menu "Build"-> "Remove project Configuration", select "Win-Release_ts",
Set Menu "Project", select "Win release_ts"
Open the Tab "Connection" and set the directory in the output file name.
[Optional] Open tab "C + +", add "preprocessor definition" ",compile_dl_<ext_name>" (note all caps, default joined), cancel predefined "Libzend_exports" (otherwise the Zend function cannot be introduced).
6, set up, compile, will generate a DLL file, filename is <ext_name>.dll, for example, in our example for the Foo.dll
Copy the Foo.dll to the E:\app\ext directory and add a row of Extension=foo.dll to the php.ini, restart Apache, see Phpinfo (), and find that our PHP extension foo () has been loaded in, You can already use this Foo extension.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service