PHP extension development-windows development environment setup

Source: Internet
Author: User
Tags vc9
1. unzip PHP-sdk to directory E: \ tang \ php_stdio \ php-sdk2, set vs2013 compiler environment variable: Open the cmd window, run vcvarsall. bat (the path is determined based on the installation path of vs) 3. create a development Directory: compile PHP

1. decompress php-sdk to the directory E: \ tang \ php_stdio \ php-sdk
2. set the vs2013 compiler environment variable: Open the cmd window and run vcvarsall. bat (the path is determined based on the installation path of)
3. create a development Directory:
Run the command prompt tool on vs2013. Note that if 64-bit is compiled, open the command prompt tool on vs2013 x64, which is x64. Switch to the E: \ tang \ php_stdio \ php-sdk directory and run:
Bin \ phpsdk_setvars.bat
Bin \ phpsdk_buildtree.bat php55dev-x64
After running, an additional php55dev-x64 directory is added to the E: \ tang \ php_stdio \ php-sdk directory.
4. decompress deps to the following Directory:
E: tang \ php_stdio \ php-sdk \ php55dev-x64 \ vc9 \ x64 \
All subdirectories in the deps directory under this directory are empty. after decompression, copy them to many necessary library files for modules/extensions.
5. Next, copy the PHP-5.5.38 source code directory to the following Directory:
E: \ tang \ php_stdio \ php-sdk \ php55dev-x64 \ vc9 \ x64 \
6. go to the php source code directory.
Cd E: \ tang \ php_stdio \ php-sdk \ php55dev-x64 \ vc9 \ x64 \ php-5.5.38
Run
Buildconf
Then you can compile php first. At the very beginning, we usually compile as few modules as possible so that the core can be compiled properly:
Configure-disable-all-enable-cli
7. compile PHP and execute
Nmake
So far, the core part of php and a command line tool are compiled.

Develop PHP extension test_extension
The basic structure of PHP extension is the same. for the convenience of PHP Development, ext_skel and ext_skel_win32.php are the extension framework building tools in linux and windows respectively. This article describes how to build a PHP extension development environment in Windows, so ext_skel_win32.php is used. With the extension framework generated by it, you can directly use VS to open the code for writing and compiling. The procedure is as follows:

1. switch to the ext Directory:
Cd E: \ tang \ php_stdio \ php-sdk \ php55dev-x64 \ vc9 \ x64 \ php-5.5.38 \ ext
2. create the file test_extension.def in the directory. the file content is the extended function to be exported, as shown below:

int a(int x, int y)string b(string str, int n)

3. run the command to generate the extension framework
Php.exe ext_skel_win32.php-extname = test_extension-proto = test_extension.def
The test_extension directory is generated.
4. go to the test_extension directory and use vs2013 to open the test_extension.dsp project file. If the 64-bit extension is compiled, change the attribute to x64 platform. Generate php_test_extension.dll after compilation.
5. put php_test_extension.dll to the ext directory of PHP, and add extension = php_test_extension.dll to the php. ini file.
6. test
Run php.exe test_extension.php (test_extnesion.php is under the generated extension framework directory)
If the extension call is successful, the following error occurs:

Functions available in the test extension:confirm_test_extension_compiledabCongratulations! You have successfully modified ext/test_extension/config.m4. Module test_extension is now compiled into PHP.

A simple PHP extension is developed in this way. pay attention to the following points:
1. pay attention to the number of file digits, 32-bit or 64-bit, which must correspond to the PHP version.
2. Note that the extension must use the same version of the compiler as PHP.

The above is a detailed description of PHP extension development-windows development environment setup. For more information, see other related articles in the first PHP community!

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.