php采集扩展,PHP扩展生成器

本文介绍了两种创建PHP扩展的方法:一是通过PHP源码包自带的`ext_skel`工具,二是使用`CodeGen_PECL`。详细步骤包括创建目录、编辑配置文件、编译和安装扩展。在使用CodeGen_PECL时,虽然出现了一些严格标准的警告,但扩展仍成功创建。对于初学者,这是了解PHP扩展开发的起点。
摘要由CSDN通过智能技术生成

第一种方法:使用PHP源码包自带的ext_skel工具。

~/public_html/php-5.3.13/ext> ./ext_skel  --extname=sample11

Creating directory sample11

Creating basic files: config.m4 config.w32 .svnignore sample11.c php_sample11.h CREDITS EXPERIMENTAL tests/001.phpt sample11.php [done].

To use your new extension, you will have to execute the following steps:

1.  $ cd ..

2.  $ vi ext/sample11/config.m4

3.  $ ./buildconf

4.  $ ./configure --[with|enable]-sample11

5.  $ make

6.  $ ./php -f ext/sample11/sample11.php

7.  $ vi ext/sample11/sample11.c

8.  $ make

Repeat steps 3-6 until you are satisfied with ext/sample11/config.m4 and

step 6 confirms that your module is compiled into PHP. Then, start writing

code and repeat the last two steps as often as necessary.

第二种方法:使用CodeGen_PECL。

/usr/local/services/php/bin> sudo ./pear install CodeGen_PECL

downloading CodeGen_PECL-1.1.3.tgz ...

Starting to download CodeGen_PECL-1.1.3.tgz (102,640 bytes)

........................done: 102,640 bytes

install ok: channel://pear.php.net/CodeGen_PECL-1.1.3

/usr/local/services/php/bin> sudo ln -s /usr/local/services/php/bin/pecl-gen /usr/local/bin/

~/public_html/php-5.3.13/ext> pecl-gen --extname=sample12

Strict Standards: Declaration of CodeGen_PECL_Element_Constant::docFooter() should be compatible with that of CodeGen_Element::docFooter() in /usr/local/services/php/lib/php/CodeGen/PECL/Element/Constant.php on line 341

Strict Standards: Declaration of CodeGen_PECL_Element_Resource::hCode() should be compatible with that of CodeGen_Element::hCode() in /usr/local/services/php/lib/php/CodeGen/PECL/Element/Resource.php on line 354

Strict Standards: Declaration of CodeGen_PECL_Element_Ini::docFooter() should be compatible with that of CodeGen_Element::docFooter() in /usr/local/services/php/lib/php/CodeGen/PECL/Element/Ini.php on line 443

Strict Standards: Declaration of CodeGen_PECL_Element_Logo::hCode() should be compatible with that of CodeGen_Element::hCode() in /usr/local/services/php/lib/php/CodeGen/PECL/Element/Logo.php on line 259

Strict Standards: Declaration of CodeGen_PECL_Element_Method::setCode() should be compatible with that of CodeGen_PECL_Element_Function::setCode() in www.2cto.com/usr/local/services/php/lib/php/CodeGen/PECL/Element/Method.php on line 471

Strict Standards: Declaration of CodeGen_PECL_Element_Stream::hCode() should be compatible with that of CodeGen_Element::hCode() in /usr/local/services/php/lib/php/CodeGen/PECL/Element/Stream.php on line 239

Your extension has been created in directory ./sample12.

See ./sample12/README and/or ./sample12/INSTALL for further instructions.

注:报错“Strict Standards: Declaration of […] should be compatible with that of […] in […]”是因为PHP5.3.0+要求子类声明必须在父类声明,,请直接修改php.ini。

error_reporting = E_ALL & ~E_STRICT

以上只是给出了生成PHP扩展的最简单的命令,ext_skel和pecl-gen还支持多种参数生成更加丰富的扩展,请自行参考相关帮助文档。

~/public_html/php-5.3.13/ext> ./ext_skel --help

~/public_html/php-5.3.13/ext> pecl-gen --help

相关报道:

Web 工程,新建Java类: [java] package leon.webtest.tags; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet. jsp .JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; pub 更多

> Web开发 > php > 正文php的扩展和嵌入--c++类的扩展开发2013-12-18 来源:cedricliang的专栏 我要投稿 今天花了几乎一天的时间研究php的相关c扩展,第一次接触的时候很多地方不太熟悉,也碰到了不少坑,这里把整个过程叙述如下,参考的文章主要是http://de 更多

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值