Configure php5.5 development environment under Windows and develop extended _php techniques

Source: Internet
Author: User
Tags php download vc9

Online tutorials are more, but I found that under the windows of the expansion of less development, and most of them are php5.3 version of the previous, today I would like to explain the expansion of PHP development, I take php5.5 version to explain the

Windows environment (my personal)

Copy Code code as follows:

Windows 8.1 Enterprise Edition (Mac OS Boot camp installed)
Visual Studio Version 2012
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 not possible to choose)

First step
Unzip the Php-sdk-binary-tools binary package, for example, I unpack into my C:\php-sdk folder, now the directory structure is as follows

Copy Code code as follows:

C:\php-sdk
--bin
--script
--share

And then, this is that you've already installed Visual Studio 2012, open VS2012 Native tools Command prompt command line tool

Copy 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 the php5.5 version, we need VC11, at which point we will take C:\php-sdk\phpdev\ Vc9 copies a copy to C:\PHP-SDK\PHPDEV\VC11, now the directory structure is as follows:

Copy 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 the deps-5.5-vc11-x86.7z into C:\php-sdk\phpdev\vc11\x86\deps folder under cover, 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 a PHP
Configure--disable-all--ENABLE-CLI
Then you'll 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_TS folder, the path is added to the environment variable, and PHP commands can be used on the command line.

Develop the first extension of PHP

If we were to develop a widuu () function, the results would be as follows

Copy Code code as follows:

function Widuu ($string) {
Return "Your the extension {$string} is OK";
}

Go to the extended directory, build the extended folder

Copy 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 own catalogue in C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext Widuuweb, opened the Widuuweb\php_widuuweb.h, in the
#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 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 a extension is ok",%.78s);
Return_stringl (string,str_len,0);
}

Then find Php_fe (confirm_widuuweb_compiled, NULL) and register your function below

Copy 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 is 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 ");
The comment at the front, vs command line, enter CD ... into the php-5.5.20 directory, enter the following command
buildconf--force
#查看扩展
Configure--help
If there is an error, you can open it, Directory Configure.js View, I have this error, is configure.js 4791 lines,
arg_enable ("Widuuweb", "ENABLE widuuweb support", "no");  * /
More than one */note, remove it, and then enter
Configure--help
See, there is a line
 --enable-widuuweb              Enable widuuweb support
Then configure
Configure--disable-all-- ENABLE-CLI--enable-widuuweb=shared
php Dynamic extension

Where--enable-widuuweb=shared is dynamically extended, just as opposed to a static extension.
then enter NMAKE, and when we do, we find the Php_widuuweb.dll file in the C:\php-sdk\phpdev\vc11\x86\php-5.5.20\Release_TS directory and we can put it into the environment for testing.
If you do not have the PHP environment installed locally, but just like I compiled PHP, if the test, I suggest static compilation look effect
Configure--disable-all--enable-cli--enable-widuuweb= Static
NMake
Then, you can then release_ts the directory and enter the
Php-r "Echo widuu (' Widuu ');"  //Output "Your The extension Widuu is ok"
OK, said here, and then slowly speaking, what do not understand you can leave a message, the basis of the ZEND_API, you can go to walu.cc view

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.