HP Source:/root/soft/php-5.3.4
PHP Installation:/usr/local/php
[Email protected] root]# phpize
Cannot find CONFIG.M4.
Make sure this you run '/usr/local/php/bin/phpize ' in the top level source directory of the module
[Email protected] root]# phpize
Cannot find CONFIG.M4.
Make sure this you run '/usr/local/php/bin/phpize ' in the top level source directory of the module
Find this tool under the/usr/local/src/php-4.3.5/ext.
To build a framework for a PHP extension
[[Email protected] ext] #cd/root/soft/php-5.3.4/ext/
[Email protected] ext]#/ext_skel--extname=my_module
Creating Directory My_module
Creating basic files:config.m4. Cvsignore my_module.c php_my_module.h CREDITS experimental TESTS/001.PHPT my_module.php [Done].
To use your new extension and you'll have to execute the following steps:
1. $ CD.
2. $ VI EXT/MY_MODULE/CONFIG.M4
3. $./buildconf
4. $./configure--[with|enable]-my_module
5. $ make
6. $./php-f ext/my_module/my_module.php
7. $ VI ext/my_module/my_module.c
8. $ make
After performing this step, you will see the result.
Repeat steps 3-6 until you is satisfied with EXT/MY_MODULE/CONFIG.M4 and
Step 6 confirms that your module is compiled into PHP. Then, start writing
Code and repeat the last steps as often as necessary.
In this way we will generate a directory under this directory called My_module
Get in here, let's see.
[Email protected] ext]# CD my_module/
[[email protected] my_module]# ls
CONFIG.M4 Experimental my_module.php tests
CREDITS my_module.c php_my_module.h
And then we're going to modify the file order Yes
Configue.m4
My_module.c
Php_my_module.h
Use a text editor to open the Config.m4 file with the following file contents:
DNL $Id $d
DNL config.m4 for extension my_module
DNL don ' t forget to call Php_extension (My_module)
DNL Comments in this file start with the string ' DNL '.
DNL Remove where necessary. This file won't work
DNL without editing.
DNL If your extension references something external, use with:
DNL Php_arg_with (My_module, for my_module support,
DNL Make sure, the comment is aligned:
DNL [--with-my_module Include my_module support])
DNL Otherwise Use enable:
DNL php_arg_enable (My_module, whether to ENABLE my_module support,
DNL Make sure, the comment is aligned:
DNL [--enable-my_module enable my_module support])
if test "$PHP _my_module"! = "no"; Then
DNL If You are not being testing anything external, like existence of
DNL headers, libraries or functions in them, just uncomment the
Dnl following line and your is ready to go.
DNL Write More examples of tests ...
Php_extension (My_module, $ext _shared)
Fi
Depending on your own choice, you will
DNL Php_arg_with (My_module, for my_module support,
DNL Make sure, the comment is aligned:
DNL [--with-my_module Include my_module support])
Modified into
Php_arg_with (My_module, for my_module support,
Make sure, the comment is aligned:
[--with-my_module Include my_module support])
or the
DNL php_arg_enable (My_module, whether to ENABLE my_module support,
DNL Make sure, the comment is aligned:
DNL [--enable-my_module enable my_module support])
Modified into
Php_arg_enable (My_module, whether to ENABLE my_module support,
Make sure, the comment is aligned:
[--enable-my_module enable my_module support])
I used the latter here.
And then save the exit
And then in the edit
Vi my_module.c
Modify the following code in the file
/* Every user visible function must a entry in my_module_functions[].
*/
Function_entry my_module_functions[] = {
Php_fe (Say_hello, NULL)/*? Add a line of code */
Php_fe (confirm_my_module_compiled, NULL)/* For testing, remove later. */
{null, NULL, NULL}/* must is the last line in my_module_functions[] */
};
Add the following code at the end of the file
Php_function (Say_hello)
{
zend_printf ("Hello world/n");
}
Save File Exit
And then we can use the above command in this directory.
/usr/local/php/bin/phpize
You will see the following after execution
[Email protected] my_module]#/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20020918
Zend Module Api no:20020429
Zend Extension Api no:20050606
[Email protected] my_module]#
Then execute./configure--enable-my_module--with-apxs=/usr/local/apache/bin/apxs--with-php-config=/usr/local/php/bin/ Php-config
We can find this file in the bin directory of the PHP after installation
Php-config and Phpize
This step must be aware of where your Apache APXS is placed.
Then execute make
You'll see that there's been an error you redefined the function of our previous
You're going to have to change this file. Delete the original function in the generated file will have the same function
You're adding your code.
It's going to pass.
At this point, a directory will be generated in the current directory called modules.
my_module.so file
CP modules/my_module.so/usr/local/php/ext/
Here you need to set up your PHP extension directory before the
Inside the php.ini.
by Extension_dir
The last one is not you open this extension in the php.ini file
Extension=my_module.so
And then
Re-starting Apache
Use Phpinfo to check the OK.
Phpize Building PHP Extensions