Under Windows Configuration php5.5 Development environment and development extension, windowsphp5.5
Online tutorials are more, but I found that in the expansion of Windows under the development of less, and most of the php5.3 version of the previous, today I will explain to you about PHP extension development, I will take php5.5 version to explain the
Windows environment (my personal)
Copy the Code code as follows:
Windows 8.1 Enterprise Edition (Mac OS Boot camp installed)
Visual Studio 2012 Release
Msysgit (http://msysgit.github.io/download)
Php-sdk-binary-tools-20110915.zip (http://windows.php.net/downloads/php-sdk/download)
deps-5.5-vc11-x86.7z (http://windows.php.net/downloads/php-sdk/download)
php-5.5.20 (http://php.net/downloads.php download, this version is uncertain about its own choice)
The first step
Unzip the Php-sdk-binary-tools binary package, such as I unzipped to my C:\php-sdk folder, now the directory structure is as follows
Copy the Code code as follows:
C:\php-sdk
--bin
--script
--share
Then, this is the command line tool that you have completed the installation of Visual Studio 2012, open VS2012 Native tools commands Prompt
Copy the Code code as follows:
#进入目录
CD C:\PHP-SDK
#设置环境变量
Bin\phpsdk_setvars.bat
#创建常用的php-SDK Directory
Bin\phpsdk_buildtree.bat Phpdev
If we open the Bin\phpsdk_buildtree.bat file we will find that it is only created to VC9, there is no VC11, but if we develop php5.5 version, we need VC11, then we will put C:\php-sdk\phpdev\ VC9 Copy to C:\php-sdk\phpdev\vc11, now the directory structure is as follows:
Copy the Code code as follows:
C:\php-sdk\phpdev\
--vc6
--vc8
--vc9
--vc11
Because I downloaded the deps-5.5-vc11-x86.7z, so I'm going to unzip deps-5.5-vc11-x86.7z to C:\php-sdk\phpdev\vc11\x86\deps folder under Overwrite, Inside are the library files we need and some necessary tools and so on.
Then, unzip the php-5.5.20.tar.bz2 we downloaded into the C:\php-sdk\phpdev\vc11\x86\php-5.5.20 folder.
Compiling and installing PHP
Back to VS2012 Native Tools Command Prompt
#进入php源目录文件夹
CD c:\php-sdk\phpdev\vc11\x86\php-5.5.20
Buildconf
#查看带的扩展和编译命令
Configure--help
Php-sdk
If you do not have PHP installed, now here to help you, you can first compile and install PHP
Configure--disable-all--ENABLE-CLI
Then you will see the 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_TS folder, the path is added to the environment variable, and the PHP command can be used on the command line.
Developing PHP's first extension
If we are going to develop a widuu () function, the effect is as follows
Copy the Code code as follows:
function Widuu ($string) {
Return "Your first extension {$string} is OK";
}
Go to the extension directory, build the extension folder
Copy the Code code as follows:
CD C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext
#输入php ext_skel_win32.php--extname= extension name
PHP ext_skel_win32.php--extname=widuuweb
At this time we saw our catalogue in C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext Widuuweb, opened Widuuweb\php_widuuweb.h, in
#PHP_MINFO_FUNCTION (Widuuweb); the next line writes its own function, for example, I define the Widuu () function
Php_function (Widuu);
Open the PHP_WIDUUWEB.C write function, under Php_function (confirm_widuuweb_compiled)
Copy the Code code 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%.78s is OK", arg_string);
Return_stringl (string,str_len,0);
}
Then find Php_fe (confirm_widuuweb_compiled, NULL) and register your function below
Copy the Code code as follows:
Const Zend_function_entry widuuweb_functions[] = {
Php_fe (confirm_widuuweb_compiled, NULL)/* For testing, remove later. */
Php_fe (Widuu,null)
Php_fe_end/* Must be the last line in widuuweb_functions[] */
};
Modify C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext\widuuweb\config.w32, remove
Arg_enable ("Widuuweb", "ENABLE widuuweb support", "no");
Front of the comment, vs command line, enter CD. To the php-5.5.20 directory, enter the following command
Buildconf--force
#查看扩展
Configure--help
If, there is an error, everyone can open, the directory under Configure.js view, I this appeared error, is Configure.js 4791 lines,
Arg_enable ("Widuuweb", "ENABLE widuuweb support", "no"); */
One More * * Comment, remove it, and then enter
Configure--help
You see, there's a line.
--enable-widuuweb Enable Widuuweb Support
Then configure
Configure--disable-all--enable-cli--enable-widuuweb=shared
PHP Dynamic Extension
Where--enable-widuuweb=shared dynamically expands, just as opposed to static scaling.
Then enter NMAKE, and when you're done, we'll find the Php_widuuweb.dll file in the C:\php-sdk\phpdev\vc11\x86\php-5.5.20\Release_TS directory, which can be tested in the environment.
If you do not have the PHP environment installed locally, but just like me compiled PHP, if the test, I recommend static compilation to see the effect
Configure--disable-all--enable-cli--enable-widuuweb=static
Nmake
Then, you can then release_ts the directory, enter
Php-r "Echo widuu (' Widuu ');"//Output "Your first extension Widuu is OK"
OK, to say here, and then slowly, what do not understand everyone can leave a message, the basis of the ZEND_API, we can go to walu.cc view
http://www.bkjia.com/PHPjc/932468.html www.bkjia.com true http://www.bkjia.com/PHPjc/932468.html techarticle under Windows Configuration php5.5 Development environment and development extension, windowsphp5.5 on-line tutorials are more, but I found that under the windows Extension development is relatively small, and most of them are php5.3 version ...