作者: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计划)。 请不要犹豫,提出意见和建议。
donkeyid, php扩展,64位自增id生成器
php 生成SITEMAP 代码 部分源码 //网址 private $weburl='http://www.wna.com/'; //更新的频率 private $frequency='weekly'; //always、hourly、daily、weekly、monthly、yearly、never //需要显示出来的扩展...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
它会在框架包中生成示例启动程序文件和目录,可用于开始构建扩展。 查看以获取安装和使用信息。 可以从phpBB.com作为的官方工具获得Skeleton Extension。贡献要从此存储库安装源代码,请将该存储库派生并克隆到...
表单设计器通常在、OA系统、问卷调查系统、考试系统、等领域发挥着重要作用! php示例 http://formdesign.leipi.org/demo.html
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
迄今为止最全面的分布式主键ID生成器。 优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 原生支持 C#/Java/Go/Rust/C/SQL 等多语言,且提供 PHP 扩展及 ...
《风越代码生成器 [FireCode Creator]》是一款采用.Net FrameWork2.0框架,基于多种数据库的程序代码生成软件,可快速建立数据信息的:添加、编辑、查看、列表、搜索页面。通过界面模板与代码模板管理功能,可自定义...
openapi生成器
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
迄今为止最全面的分布式主键ID生成器。优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 原生支持 C#/Java/Go/Rust/C/SQL 等多语言,且提供 PHP 扩展及 ...
本分布式主键ID生成器基于多语言优化,包含204个文件,包括Markdown文档、Dockerfile、Go源代码、Java源代码、GIT忽略文件、Header文件、C#源代码、C源代码、Pascal源代码、Rust源代码。系统采用优化的雪花算法...
通过自定义生成程序的界面风格与输出代码,用户可将其扩展为ASPX/ASP/PHP/JSP等各种程序的代码生成器。内置的.net代码框架,能建立C#语言的.net解决方案,可在VS2005中直接编辑,既能帮助.net初学者快速入门,更可...
最全面的分布式主键ID生成器。 优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 原生支持 C#/Java/Go/Rust/C/SQL 等多语言,且提供 PHP 扩展及 Python、...
:backhand_index_pointing_right: 此自定义PHP库取决于SweetAlert2 JS库,并且该php类用作Javascript代码生成器。安装安装此扩展的首选方法是通过 。 要安装VSP_Framework库,只需: $ composer require ...