PHP Module Learning (1) Preliminary PHP Module

xiaoxiao2021-03-06  111

It is not very difficult to write PHP Module, and the reference articles are:

Write your own PHP extension function

Zend Manual

This article mainly said the compilation process

1 Locate the source code of PHP, decompress (if you have installed the original installation source code)

2 Use the tool "ext_skel" to initialize the module code, this tool is written for you, some of the necessary code: {phpSRC} / ext / ext_skel _extName = module name first go to {phpSRC} / ext / directory, then execute

-------------

./ext_skel --extName = my_module

-------------

This tool will create a directory that is the same as the module name in ext /, and creates some related code. 3 Modify config.m4 files

File Location: {PHPSRC} / EXT / Module Name /config.m4

Modifying method: Remove and the module related to the several lines of comments (3 lines) (remove DNL, ​​optional with, enable, I chose with whom, because the letters are less: P)

4 Modify the generated code, create your own functions

How to modify this section can refer to Zend Manual to make your own functional function

I added a function weiping (); output "Welcome to my homepage:

http://www.wmsp.org "

Details in Yorgo Su's articles

5 Return to {PHPSRC} Run Tool Buildconf

Sometimes it may be enforced with buildconf --force

6 Configure reconfiguration

./configure --with-module name

7 Make

Don't say more, play MAKE

8 test

Write a test function in your module, then use the just compiled PHP to execute

9 recompile Apache, join the new PHP module libphp4.a

Next: PHP Module Learning (II) Analysis of Zend Engine (Sedening)

related articles:

CONFIG.M4

Buildconf

转载请注明原文地址:https://www.9cbs.com/read-103948.html

New Post(0)