Home >Backend Development >PHP Tutorial >Configuring the php5.5 development environment and development extensions under windows, windowsphp5.5_PHP tutorial
There are many tutorials on the Internet, but I found that there are relatively few extension development under windows, and most of them are before php5.3 version. Today I will explain to you php extension development, I will use php5. I’ll explain it in version 5
windows environment (my personal one)
Step 1
Unzip the binary package of php-sdk-binary-tools. For example, I unzipped it to my C:php-sdk folder. The current directory structure is as follows
Then, after you have installed visual studio 2012, open the VS2012 Native Tools Command Prompt command line tool
If we open the binphpsdk_buildtree.bat file, we will find that it is only created to VC9, not VC11, but if we develop the php5.5 version, we need VC11. At this time, we need to copy C:php-sdkphpdevvc9 Copy to C:php-sdkphpdevvc11. The current directory structure is as follows:
Because I downloaded deps-5.5-vc11-x86.7z, I need to unzip deps-5.5-vc11-x86.7z and overwrite it in the C:php-sdkphpdevvc11x86deps folder. It contains the library files and files we need. Some necessary tools etc.
Then, unzip the php-5.5.20.tar.bz2 we downloaded into the C:php-sdkphpdevvc11x86php-5.5.20 folder.
Compile and install php
Back to VS2012 Native Tools Command Prompt
#Enter the php source directory folder
cd c:php-sdkphpdevvc11x86php-5.5.20
buildconf
#View the extension and compilation commands with the band
configure --help
php-sdk
If you have not installed php, this will help you now. You can compile and install php first
configure --disable-all --enable-cli
Then, you will see Type 'nmake' to build PHP, then compile
nmake
The php.exe file is generated in the C:php-sdkphpdevvc11x86php-5.5.20Release_TS folder. Add this path to the environment variable, so that you can use the php command on the command line.
Developing the first extension for PHP
If we want to develop a widuu() function, the effect is as follows
Enter the extension directory and generate the extension folder
Then find PHP_FE(confirm_widuuweb_compiled, NULL) and register your function below
Modify C:php-sdkphpdevvc11x86php-5.5.20extwiduuwebconfig.w32 and remove
// ARG_ENABLE("widuuweb", "enable widuuweb support", "no");
Previous comments, vs command line, enter cd .. Go to the php-5.5.20 directory and enter the following command
buildconf --force
#View extension
configure --help
If there is an error, you can open it and check configure.js in the directory. I had an error, which is line 4791 of configure.js,
ARG_ENABLE("widuuweb", "enable widuuweb support", "no"); */
There is an extra */ comment, just remove it, and then enter
configure --help
Just saw it, there is a line
--enable-widuuweb enable widuuweb support
Then configure
configure --disable-all --enable-cli --enable-widuuweb=shared
php dynamic extension
Among them, --enable-widuuweb=shared dynamic expansion is exactly the opposite of static expansion.
Then enter nmake. After completion, we found the php_widuuweb.dll file in the C:php-sdkphpdevvc11x86php-5.5.20Release_TS directory, which can be placed in the environment for testing.
If you do not have a PHP environment installed locally, but just compiled PHP like me, if you want to test, I recommend static compilation to see the effect
configure --disable-all --enable-cli --enable-widuuweb=static
nmake
Then, you can enter
in the Release_TS directory
php -r "echo widuu('widuu');" //Output "your first extension widuu is ok"
ok, that’s it for now. I’ll talk about it slowly in the future. If you don’t understand anything, you can leave a message. For the basic ZEND_API, you can check it out at walu.cc