Windows WAMP PHP Extension Development

Source: Internet
Author: User
Tags phpinfo
1. Development readiness
Install Wamp, which is in Wampserver version 2.5, with PHP version 5.5.12.
Wamp installation directory: D:\wamp
Apache Directory: D:\wamp\bin\apache
PHP Directory: D:\wamp\bin\php
Download PHP-5.5.12 source package, unzip to any directory. Example: E:\php-5.5.12
2. Through Phpinfo () query the PHP version of the compilation of information, the main view:
Compiler MSVC11 (Visual C + + 2012)
Architecture x86
Zend Extension Build Api220121212,ts,vc11
PHP Extension Build Api20121212,ts,vc11
As you can see from the above information, PHP Wampserver 2.5 is compiled by MSVC11 (VS2012) in x86 (Win32) and the TS (Thread Safe) attribute is set.
So the same compilation environment and TS settings are required to compile the extension (the default value is TS)
3. Generate the Config.w32.h file required to compile the plugin
Open the VS2012 Developer command Prompt and enter the E:\php-5.5.12 directory;
Executes the Buildconf.bat command, which generates a configure.js file in the current directory;
Executes the Configure command to generate the E:\php-5.5.12\main\config.w32.h file.
If bison related errors occur during execution, you do not have Bison installed, you can open the Configure.js file and comment The following three lines, and then re-execute the Configure command.
if (! Path_prog (' bison ')) {
ERROR (' Bison is required ')
}
Why this can be done, because we don't need to compile PHP, we just need to build the Config.w32.h file to compile the extension.
4. Plugin compilation File Preparation
Enter the E:\php-5.5.12\ext directory, copy the E:\php-5.5.12\ext\skeleton directory, and rename the name you need to develop the plugin, such as My_plugin;
Rename Php_skeleton.h,skeleton.c and SKELETON.DSP to Php_my_plugin.h,my_plugin.c and MY_PLUGIN.DSP;
Open the above three files respectively, replace the extname in the file with the My_plugin,extname Replace with My_plugin (ensure the case is consistent);
Copy the D:\wamp\bin\php\php5.5.12\dev\php5ts.lib to the My_plugin directory.
5. Compile the plugin and install
Using VS2012 to open the My_plugin.dsp file, select RELEASE_TS (Generate release version) and configure compile to C code (solution Properties-Configuration Properties-c/c++-advanced-compile to-compile to C code (/TC));
Compile the solution and generate the Php_my_plugin.dll file (located in the E:\php-5.5.12\Release_TS directory) corresponding to the plugin;
Copy the compiled DLL file to the wamp PHP extension directory (D:\wamp\bin\php\php5.5.12\ext);
Edit the D:\wamp\bin\apache\apache2.4.9\bin\php.ini file, look for the "extension=" keyword and add "Extension=php_my_plugin.dll" after the original PHP plugin;
Special Note: The edited php.ini is not D:\wamp\bin\php\php5.5.12\php.ini, since Wamp initializes PHP, the read position is in the D:\wamp\bin\apache\apache2.4.9\bin\ php.ini file.
Restart the Apache server.
6. Test Plug-ins
If the plugin is successfully loaded, restarting the Apache server to access Phpinfo () will see the newly added My_plugin plugin.
Generate the my_plugin_test.php file and place it in the D:\wamp\www directory with the following contents:
Echo confirm_my_plugin_compiled ("My_plugin");
?>
Using the browser to access the new my_plugin_test.php file above, the following page appears, indicating that the plugin is working properly:
congratulations! You have successfully modified EXT/MY_PLUGIN/CONFIG.M4. Module My_plugin is now compiled to PHP.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes the Windows WAMP PHP extension development, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.