PHP extension programming in Windows-PHP source code

Source: Internet
Author: User
Ec (2); although PHP provides a large number of useful functions, it may also require extended programming in special circumstances, such as a large number of PECL (PHPExtensionCommunityLibrary) it is provided in an extended form (Dynamic Link Library dll files), which is much more efficient than PEAR. & Nbsp; PHP extensions are written in C or C ++ and need to be compiled into the dynamic Connection Library dll File script ec (2); script

Although PHP provides a large number of useful functions, Extension programming may be required in special cases, such as a large number of PECL (PHP Extension Community Library) it is provided in an extended form (Dynamic Link Library dll files), which is much more efficient than PEAR.
PHP extensions are written in C or C ++ and need to be compiled into dynamic Connection Library dll files before they can be used after registration in the PHP environment.
PHP extension software requirements:
VC ++ 6.0 or VC ++. NET environment.
PHP source code, which must be compiled.
If you do not want to compile the PHP source code, you can download the compiled binary code of PHP (that is, the packages for deploying the PHP runtime environment ). Note that the downloaded source file packages and compiled packages must be of the same version.

Process:

1. Install VC ++ 6.0 and add its executable file path to the environment variable so that the compiler can be run in any path of the command line environment.
2. Install the PHP runtime environment and integrate it with IIS correctly. Assuming the PHP version used is 5.2.5, download the php-5.2.5-Win32.zip Binary Package and the php-5.2.5.tar.gz source code package. The installation environment is C: php-5.2.5-Win32. Decompress the source code package and Binary Package to this folder. Copy php. ini-recommended to generate a php. ini file.
3, create a C: php-5.2.5-Win32Release_TS folder, copy the C: php-5.2.5-Win32devphp5ts.lib file here.
4, enter the C: php-5.2.5-Win32ext folder, run the command:
C: php-5.2.5-Win32ext> ..php.exe ext_skel_win32.php -- extname = myphpext
Creating directory myphpext
Creating basic files: config. m4 config. w32. cvsignore myphpext. c php_myphpext.h
Credits experimental tests/001. phpt myphpext. php [done].

To use your new extension, you will have to execute the following steps:

1. $ cd ..
2. $ vi ext/myphpext/config. m4
3. $./buildconf
4. $./configure -- [with | enable]-myphpext
5. $ make
6. $./php-f ext/myphpext. php
7. $ vi ext/myphpext. c
8. $ make

Repeat steps 3-6 until you are satisfied with ext/myphpext/config. m4 and
Step 6 confirms that your module is compiled into PHP. Then, start writing
Code and repeat the last two steps as often as necessary.

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.