作者:zhanhailiang 日期:2013-02-05
第一种方法:使用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 /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+不允许子类方法签名与父类方法签名不匹配导致的,以上例第一个严格错误提示:
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
如下对比CodeGen_PECL_Element_Constant和CodeGen_Element的docFooter方法的声明的差异:
/usr/local/services/php/lib/php/CodeGen> grep -Rn "class CodeGen_PECL_Element_Constant" .
./PECL/Element/Constant.php:39:class CodeGen_PECL_Element_Constant
/usr/local/services/php/lib/php/CodeGen> grep -Rn "class CodeGen_Element" .
./Element.php:33:abstract class CodeGen_Element
// ./PECL/Element/Constant.php
330 /**-
331 * Generate DocBook XML section block footer
332 *
333 * @access public
334 * @param string Extension name
335 * @return string DocBook XML snippet
336 */
337 static function docFooter()
338 {
339 return " </variablelist>\n";
340 }
341 }
342
343 ?>
// ./Element.php
292 /**
293 * Generate documentation footer block for all elements of this class
294 *
295 * @access public
296 * @param string Extension name
297 * @return string documentation fragment
298 */
299 static function docFooter($name)
300 {
301 return "";
302 }
303
304 }
305
306 ?>
请直接修改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
其中,pecl-gen支持从XML中导入生成扩展的强大功能,参见文档:CodeGen_PECL
- the PHP extension generator
分享到:
相关推荐
php-ext-gen PHP 扩展生成器。 有关详细信息,请参阅。 这是一个 alpha 版本。 只生成定义函数、常量和INI条目的代码,唯一实现的生成器是PHP5(PHP7和HHVM计划)。 请不要犹豫,提出意见和建议。
虽然这个资源是以Oracle为例,但通常代码生成器会设计成可配置或可扩展的,允许用户根据需要修改数据库连接参数,以适应MySQL、PostgreSQL等其他数据库。这涉及到对不同数据库驱动的了解,如PDO(PHP Data Objects)...
ASP/PHP代码生成器是一款专为ASPPHP程序员设计的工具,旨在提高开发效率和减少重复劳动。这个软件能够自动生成常见的ASP或PHP代码,帮助程序员快速构建网站应用的基础架构,从而将更多精力集中在业务逻辑和创新功能...
标题 "PHP数据生成器数据库工具" 指的是一种用于PHP开发中的实用程序,它能够帮助开发者快速生成大量模拟数据,以填充测试数据库或者在项目初期建立数据模型。这种工具通常包含一系列预定义的数据类型和规则,使得...
田字格笔顺字帖在线生成器是一款基于PHP开发的软件工具,主要用于帮助用户便捷地创建含有正确笔顺的田字格字帖。这款源码包含9574个常用汉字,覆盖了日常生活中最频繁使用的汉字,对于学习汉字书写、教授汉字笔顺...
7. **优化和自定义**:通常,该工具会提供配置选项,允许开发者根据自己的项目需求调整生成代码的样式和结构,甚至可以扩展生成器的功能。 通过使用Thinkphp代码生成器,开发者能够快速搭建项目基础架构,从而将更...
【标题】"基于PHP的田字格笔顺字帖在线生成器php源码.zip" 描述了一款使用PHP编程语言开发的在线工具,该工具能够自动生成田字格笔顺字帖。田字格是一种传统的汉字练习模板,帮助学习者准确掌握汉字的笔画顺序和位置...
该PHP实例开发源码是一个田字格笔顺字帖...通过深入理解这些技术点,开发者不仅可以实现田字格笔顺字帖在线生成器的功能,还能扩展其功能,例如添加字帖打印、分享到社交媒体等功能,从而提升项目的实用性和吸引力。
在PHP中,这个按钮生成器可能使用GD库或者ImageMagick等图像处理扩展来创建和编辑图像。GD库是PHP内建的图像处理库,支持创建、修改和输出多种图像格式,如PNG、JPEG和GIF。而ImageMagick是一个功能更强大的命令行...
"php/cms/ecshop标签生成器"是一个针对ECShop的扩展工具,旨在帮助开发者更便捷地创建和管理自定义标签,提升网站的个性化和用户体验。 在ECShop中,标签是一种动态内容生成机制,允许开发者在模板文件中嵌入特定的...
总的来说,`donkeyid`是一个优秀的PHP扩展,它为开发人员提供了生成64位自增ID的能力,特别适合于分布式环境,保证了ID的全局唯一性、有序性和高性能。通过深入学习和应用`donkeyid`,开发者能够更好地应对大数据...
标题中的“基于PHP的CSS3代码在线生成生成器php版源码.zip”表明这是一个使用PHP编程语言开发的项目,主要用于创建CSS3代码的在线工具。这个工具允许用户通过Web界面生成CSS3样式,无需手动编写复杂的CSS3语法,提高...
14. 扩展生成器:介绍两个常用的扩展生成器:ext_skel和PECL_Gen。 15. 设置宿主环境:学习如何嵌入PHP到宿主应用程序中,包括嵌入式SAPI的使用,构建和编译宿主应用。 16. 高级嵌入式:涵盖在PHP中进行回调,错误...
首先,让我们了解为何要编写PHP扩展。有四个主要理由: 1. PHP语言的抽象程度使得某些库或操作系统特定调用无法直接进行。 2. 想要让PHP以非传统方式运行。 3. 已有的PHP代码可以优化,使其运行更快、体积更小、...
7. **应用场景**:Freetype在Web开发中的应用广泛,例如在图像生成库GD中用于生成带文字的图片,或者在PDF生成器中用于高质量的文本排版。同时,它也是许多图形处理软件和游戏引擎的重要组成部分,用于处理字体显示...
这个标签生成器可以帮助开发者快速创建PbootCMS中的自定义标签,避免手动编写繁琐的PHP代码。通过使用这个工具,你可以输入必要的参数,如标签名称、调用的模型、字段选择等,然后生成相应的标签代码,直接复制到...
这使得代码生成器不仅限于基本的CRUD操作,还能扩展到复杂的业务场景。 6. **后期维护**:在项目开发过程中,当数据库结构发生变化时,如新增、修改或删除字段,只需重新运行代码生成器,即可快速更新相关代码,...
8. **可扩展性**:好的代码生成器应支持自定义模板,允许开发者按照自己的项目需求进行定制,提高代码的可维护性和可扩展性。 9. **易用性**:PHPCMS V9代码生成器 2.0应该提供直观的图形用户界面,让用户可以通过...
这篇博文“参考MongoDB输入格式的SQL生成器 by PHP”提供了一个PHP工具,能够帮助开发者将MongoDB的数据格式转换为SQL查询。 `CSQLGen.php`文件可能是这个工具的核心实现,它可能包含了一个类或函数,接收MongoDB的...