c写的php module

我不熟悉c, 也不熟悉php, 所以为了能实现用c写php module的功能, 着实还是费了点儿周折。

在php源代码包中,已经包含了生成php module的脚本配置方案, 按照下列步骤即可:

当前目录: /*/*/php-*/ext

1. ./ext_skel extname="hello"
生成名为 “hello”的模块
并生成3个模板文件: hello.c  hello.php  php_hello.h

2. cd hello
   vim config.m4
   删除以下语句的注释
    PHP_ARG_ENABLE(hello, whether to enable hello support,
    Make sure that the comment is aligned:
    [  --enable-hello           Enable hello support])
   注意此处不能使用 --with参数
 
3. phpize
   为此模块生成配置文件

4. ./configure

5. make
   在modules中生成hello.la  hello.so两个文件

6. make test

7. make install
   将hello.so文件cp到$PHP_HOME/lib/php/extensions/no-debug-non-zts-*/

10. php -f hello.php
    返回结果如下:
    Functions available in the test extension:
    confirm_hello_compiled

    Congratulations! You have successfully modified ext/hello/config.m4. Module hello is now compiled into PHP.

11.编译成功。

剩下的工作就是修改 hello.c  hello.php  php_hello.h, 实现自己的功能需求,并重复执行5-10.

在web中调用hello.so, 还需要以下2步:  

1. 在php.ini中设置so加载项
    extension=hello.so

2. 重新启动php
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值