The first step: Build an extended skeleton.
[HTML]
cd/usr/local/src/php-5.3.6/ext/
./ext_skel--extname=laiwenhui
cd/usr/local/src/php-5.3.6/ext/
./ext_skel--extname=laiwenhui Step Two: Modify the compilation parameters.
[HTML] View PLAINCOPYPRINT?CD Php-5.3.6/ext/laiwenhui
VI CONFIG.M4
CD Php-5.3.6/ext/laiwenhui
VI config.m4 Remove
Php_arg_enable (Laiwenhui, whether to ENABLE Laiwenhui support,
[--enable-laiwenhui enable Laiwenhui support])
DNL in front of two lines
Modified to:
DNL Otherwise Use enable:
Php_arg_enable (Laiwenhui, whether to ENABLE Laiwenhui support,
DNL Make sure, the comment is aligned:
[--enable-laiwenhui enable Laiwenhui support])
Step Three: Write code
[HTML]
Vim php_laiwenhui.h
Vim php_laiwenhui.h
In
Php_function (confirm_laiwenhui_compiled);
Add a row later
Php_function (test);
[HTML]
Vim LAIWENHUI.C
Vim LAIWENHUI.C
In
Php_fe (confirm_laiwenhui_compiled, NULL)
Added later
Php_fe (test, NULL)
* * Add the following code to the last side of the file: *
[HTML]
Php_function (Test)
{
Char *arg = "This is my first extention!";
int Len;
Char *STRG;
Len = spprintf (&STRG, 0, "%s\n", Arg);
Return_stringl (STRG, Len, 0);
}
Php_function (Test)
{
Char *arg = "This is my first extention!";
int Len;
Char *STRG;
Len = spprintf (&STRG, 0, "%s\n", Arg);
Return_stringl (STRG, Len, 0);
Step Fourth: Compile the Code
[HTML]
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
My PHP installation path is:/usr/local/php
This time a file is generated/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/laiwenhui.so
To edit the PHP configuration file php.ini, add the extension:
[HTML]
Vim php.ini
Vim PHP.ini added under [PHP] module:
[HTML]
Extension = laiwenhui.so
Extension = laiwenhui.so Modify the Extension_dir in the php.ini file to this directory:
[HTML]
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
Fifth Step: Check the installation results
1. Restart Php-fpm,ngixn
2./use/local/php/bin/php-m
See if there is a laiwenhui extension included.
Sixth step: Execute the test code
Create test.php at the site root directory
Vim test.php
Code content is as follows
echo Test ();
The results after execution are:
This is my first extention!
If you can successfully complete the above steps, congratulations on completing the first extension.
http://www.bkjia.com/PHPjc/477166.html www.bkjia.com true http://www.bkjia.com/PHPjc/477166.html techarticle The first step: Build an extended skeleton. [HTML] cd/usr/local/src/php-5.3.6/ext/./ext_skel--extname=laiwenhui cd/usr/local/src/php-5.3.6/ext/./ext_skel-- Extname=laiwenhui Second step: Repair ...