This article mainly introduces how to configure the php5.5 Development Environment and Development extension in windows. It is very detailed and comprehensive. It is a very good basic php article. We recommend it to you here.
This article mainly introduces how to configure the php5.5 Development Environment and Development extension in windows. It is very detailed and comprehensive. It is a very good basic php article. We recommend it to you here.
There are a lot of online tutorials, but I found that there are few extension development projects in windows, and most of them are earlier than php5.3. Today I will explain to you about php extension development ,, let's take php5.5 as an example.
Windows (my personal)
The Code is as follows:
Windows 8.1 Enterprise Edition (installed on mac OS Boot Camp)
Visual Studio 2012
Msysgit (download)
Php-sdk-binary-tools-20110915.zip (download)
Deps-5.5-vc11-x86.7z (download)
Php-5.5.20 (download, this version may not be your choice)
Step 1
Decompress the php-sdk-binary-tools binary Package. For example, if I decompress the package to my C: \ php-sdk folder, the current directory structure is as follows:
The Code is as follows:
C: \ php-sdk
-- Bin
-- Script
-- Share
Then, you have installed visual studio 2012. Open the VS2012 Native Tools Command Prompt Command line tool.
The Code is as follows:
# Enter the Directory
Cd C: \ php-sdk
# Setting Environment Variables
Bin \ phpsdk_setvars.bat
# Create common php-sdk Directories
Bin \ phpsdk_buildtree.bat phpdev
If we open the bin \ phpsdk_buildtree.bat file, we will find that it is only created to VC9 without VC11. But if we develop php5.5, we need VC11. At this time, we need to put C: copy \ php-sdk \ phpdev \ vc9 to C: \ php-sdk \ phpdev \ vc11. The directory structure is as follows:
The Code is as follows:
C: \ php-sdk \ phpdev \
-- Vc6
-- Vc8
-- Vc9
-- Vc11
Because I downloaded deps-5.5-vc11-x86.7z, I used deps-5.5-vc11-x86.7z to extract deps-5.5-vc11-x86.7z to the C: \ php-sdk \ phpdev \ vc11 \ x86 \ deps folder, which included library files and necessary tools.
Then decompress the downloaded php-5.5.20.tar.bz2 to the C: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20 folder.
Compile and install php
Return to VS2012 Native Tools Command Prompt
# Enter the php source directory folder
Cd c: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20
Buildconf
# View the extended and compiled commands
Configure -- help
Php-sdk
If you have not installed php, it will help you now. Compile and install php first.
Configure -- disable-all -- enable-cli
Then, you will see Type 'nmake' to build PHP, and then compile
Nmake
The php.exe file is generated under the C: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20 \ release_tsfolder, and this path is added to the environment variables. Fortunately, php commands can be used in the command line.
Develop the first extension of PHP
If we want to develop a widuu () function, the implementation effect is as follows:
The Code is as follows:
Function widuu ($ string ){
Return "your first extension {$ string} is OK ";
}
Enter the extension directory to generate the extension folder
The Code is as follows:
Cd C: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20 \ ext
# Input php ext_skel_win32.php -- extname = extension name
Php ext_skel_win32.php -- extname = widuuweb
At this time we in C: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20 \ ext to see their own directory widuuweb, open widuuweb \ php_widuuweb.h, in
# PHP_MINFO_FUNCTION (widuuweb); write your own function in the next row. For example, I define the widuu () function.
PHP_FUNCTION (widuu );
Open php_widuweb.c and compile the function. Under PHP_FUNCTION (confirm_widuweb_compiled ),
The Code is as follows:
PHP_FUNCTION (widuu ){
Char * arg_string = NULL;
Int arg_len, str_len;
Char * string;
If (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC, "s", & arg_string, & arg_len) = FAILURE ){
Return;
}
Str_len = spprintf (& string, 0, "your first extension %. 78 s is OK", arg_string );
RETURN_STRINGL (string, str_len, 0 );
}
Then find PHP_FE (confirm_widuweb_compiled, NULL) and register your function below
The Code is as follows:
Const zend_function_entry widuweb_functions [] = {
PHP_FE (confirm_widuuweb_compiled, NULL)/* For testing, remove later .*/
PHP_FE (widuu, NULL)
PHP_FE_END/* Must be the last line in widuweb_functions [] */
};
Modify C: \ php-sdk \ phpdev \ vc11 \ x86 \ php-5.5.20 \ ext \ widuuweb \ config. w32, remove
// ARG_ENABLE ("widuuweb", "enable widuweb support", "no ");
Comments to the front, vs command line, enter cd... To the php-5.5.20 directory, enter the following command
Buildconf -- force
# View extensions
Configure -- help
If there is an error, you can open it and check configure. js in the directory. This error is reported in line 4791 of configure. js,
ARG_ENABLE ("widuuweb", "enable widuweb support", "no ");*/
With an additional */comment, you can remove it and then enter
Configure -- help
We can see that there is a line
-- Enable-widuweb enable widuuweb support
Then configure
Configure -- disable-all -- enable-cli -- enable-widuweb = shared
Php Dynamic Scaling