php扩展开发步骤

为什么要写扩展,这里就不在展开说了,网上有很多这方面的知识,这里只说明下开发一个扩展的几个步骤:

1,cd /usr/local/src/php-5.3.6/ext,切换到php的代码目录下
2,./ext_skel --extname=your_ex_tname 使用ext_skel创建一个扩展的框架

1. $ cd ..
2. $ vi ext/your_ext_name/config.m4
3. $ ./buildconf
4. $ ./configure --[with|enable]-your_ext_name
5. $ make
6. $ ./php -f ext/your_ext_name/your_ext_name.php
7. $ vi ext/your_ext_name/your_ext_name.c
8. $ make


3,安装第二部的提示,修改config.m4
去掉

dnl PHP_ARG_ENABLE(your_ext_name, whether to enable your_ext_name support,
dnl Make sure that the comment is aligned:
dnl [ --enable-your_ext_name Enable your_ext_name support])


修改后为:


PHP_ARG_ENABLE(your_ext_name, whether to enable your_ext_name support,
Make sure that the comment is aligned:
[ --enable-your_ext_name Enable your_ext_name support])


4,编写扩展的代码:
vim your_ext_name.h在PHP_FUNCTION(confirm_your_ext_name_compiled);下面增加声明函数

vim your_ext_name.c编写实现代码

5,编译代码:
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

6,修改php.ini加载your_ext_name.so,重启web server后用phpinfo查看扩展是否加载成功。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值