PHP expansion programming under Windows

Source: Internet
Author: User
Although PHP provides a number of useful functions, it may be necessary to extend programming in special cases, such as a large number of PECL (PHP Extension Community Library) are provided in an extended form (DLL file for dynamic link), which is more than the PEAR Operation efficiency is much higher.
PHP extensions are written in C or C + + and need to be compiled into a dynamic connection library DLL file after registration in the PHP environment to use.
Software Requirements for writing PHP extensions:
vc++6.0 or vc++.net environment.
PHP source code, need to compile.
If you don't want to compile PHP's source code, you can download PHP's already compiled binary code (which is the package we deployed in the PHP runtime Environment). Note the source packages and compiled packages that are downloaded separately must be the same version.

Process:

1, install vc++6.0 and choose to add its executable path to the environment variable so that you can run the compiler under any path in the command line environment.
2, install the PHP running environment and integrate with IIS correctly. Suppose you use a PHP version of 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. Extract the source code package and binary package into the folder separately. Generates a php.ini file from the php.ini-recommended copy.
3, set up C:php-5.2.5-win32release_ts folder, copy c:php-5.2.5-win32devphp5ts.lib file to here.
4, go to the C:php-5.2.5-win32ext folder and 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'll 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/myphpext.php
7. $ VI ext/myphpext/myphpext.c
8. $ make

Repeat steps 3-6 until you are satisfied with EXT/MYPHPEXT/CONFIG.M4 and
Step 6 confirms the 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.