Home >Backend Development >PHP Tutorial >Configuring the php5.5 development environment and development extensions under windows, windowsphp5.5_PHP tutorial

Configuring the php5.5 development environment and development extensions under windows, windowsphp5.5_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:10:54876browse

Configure php5.5 development environment and development extensions under windows, windowsphp5.5

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)

Copy code The code is as follows:

Windows 8.1 Enterprise Edition (installed with mac os Boot Camp)
Visual Studio 2012 version
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 (Download from http://php.net/downloads.php, you may choose this version)

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

Copy code The code is as follows:

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

Then, after you have installed visual studio 2012, open the VS2012 Native Tools Command Prompt command line tool

Copy code The code is as follows:

#Enter directory
cd C:php-sdk
#Set environment variables
binphpsdk_setvars.bat
#Create commonly used php-sdk directory
binphpsdk_buildtree.bat phpdev

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:

Copy code The code is as follows:

C:php-sdkphpdev
--vc6
--vc8
--vc9
--vc11

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

Copy code The code is as follows:

function widuu($string){
Return "your first extension {$string} is ok";
}

Enter the extension directory and generate the extension folder

Copy code The code is as follows:

cd C:php-sdkphpdevvc11x86php-5.5.20ext
#Enter php ext_skel_win32.php --extname=extension name
php ext_skel_win32.php --extname=widuuweb

At this time we saw our own directory widuuweb in C:php-sdkphpdevvc11x86php-5.5.20ext, open widuuwebphp_widuuweb.h, in
#PHP_MINFO_FUNCTION(widuuweb); Write your own function in the next line, for example, I define the widuu() function
PHP_FUNCTION(widuu);
Open php_widuuweb.c to write the function, under PHP_FUNCTION (confirm_widuuweb_compiled)

Copy code 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 %.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 code The code is 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-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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/932468.htmlTechArticleConfiguring the php5.5 development environment and development extensions under windows. There are many online tutorials for windowsphp5.5, but I found that there are relatively few extension developments under windows, and most of them are php5.3 version...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn