Detailed WINDOW7 development of PHP extension _php instance

Source: Internet
Author: User
Tags php script vc9 win32

First, view phpinfo () information

PHP Version 5.4.34
Zend Extension Build Api220100525,ts,vc9
PHP Extension Build Api20100525,ts,vc9
Thread Safety Enable

Thread safe, VC9 compiled, version 5.4.34

Ii. Pre-development preparatory work

PHP 5.3-5.4:visual C + + 9.0 (Visual Studio 2008)
Install Cygwin (download address: http://www.cygwin.com/), Virtual Linux environment
PHP compiled program and pre-compiled source code (download address: http://windows.php.net/download/)
Compiled program path: php-5.4.45-win32-vc9-x86\
Pre-compile source path: php-5.4.45-src\
Download the PHP SDK file, http://windows.php.net/downloads/php-sdk/

1, decompression php-sdk-binary-tools-20110915.zip inside the file, will bison.exe in the Bin directory added system path

Copy Php-5.4.45-win32-vc9-x86\dev\php5ts.lib to Php-5.4.45-src\release_ts\php5ts.lib
New Php-5.4.45-src\main\config.win32.h, which reads as follows:
#define Sizeof_long 4
#define PHP_COMPILER_ID "VC9"
"VC9" corresponds to VC9

2, find the PHP source directory, php-5.4.45-src\ext\ext_skel_win32.php

/* This
script can is used on Win
systems) Make sure your have CygWin installed
) Adjust the $cygwin _path to M Atch your installation
) change the environment cariable Pathext to include. PHP
) Run Ext_skel--extname=
... The I/Run this script is asked to
associate it with a program chooses the CLI version of Php.
   */

This is changed to your Cygwin installation directory.

3, run cmd, enter the PHP source directory, Php-5.4.45-src\ext, run the command php ext_skel_win32.php--extname=myphpexs


Remember to add the Php.exe directory to path,--extname= your extended name,

If successful will be in the EXT directory to generate Myphpexs folder, the contents are as follows


4, with vs2008 open MYPHPEXS.DSP, solution configuration change to release, execute Build command

If it goes well, it will generate the Php_myphpexs.dll file, and my php_myphpexs.dll will be generated again in the Release_ts folder of the PHP source root directory

5, put the php_myphpexs.dll into your PHP extension directory, and then php.ini add Extension=php_myphpexs.dll

6, the new PHP script file test.php, the contents are as follows

Copy Code code as follows:

echo confirm_myphpexs_compiled (' Test ');

7, run the test file, the following contents of the description, successful

Copy Code code as follows:

congratulations! You have successfully modified EXT/MYPHPEXT/CONFIG.M4. The Module is now compiled into PHP.

8, confirm_myphpexs_compiled is to establish an extension is the number of the function of the book, in editing your own extended content, you can delete the change function

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.