php 创建一个扩展开发环境的正确姿势
来源:互联网 发布:odis工程师刷低层数据 编辑:程序博客网 时间:2024/06/05 05:52
安装编译PHP
官网下载最新php-7.1.5.tar的源码包
设置开发目录,打开调试模式,禁止其他内置模块
cd path/to/php-src./configure --prefix=path/to/php --enable-debug --disable-allmake && make install
生成PHP扩展目录
cd php-src/ext./ext_skel --extname=my_helloworldCreating directory my_helloworldCreating basic files: config.m4 config.w32 .gitignore my_helloworld.c php_my_helloworld.h CREDITS EXPERIMENTAL tests/001.phpt my_helloworld.php [done].To use your new extension, you will have to execute the following steps:1. $ cd ..2. $ vi ext/my_helloworld/config.m43. $ ./buildconf4. $ ./configure --[with|enable]-my_helloworld5. $ make6. $ ./sapi/cli/php -f ext/my_helloworld/my_helloworld.php7. $ vi ext/my_helloworld/my_helloworld.c8. $ makeRepeat steps 3-6 until you are satisfied with ext/my_helloworld/config.m4 andstep 6 confirms that your module is compiled into PHP. Then, start writingcode and repeat the last two steps as often as necessary.
编辑扩展文件config.m4
去掉这几行的 dnl 注释前缀
PHP_ARG_ENABLE(my_helloworld, whether to enable my_helloworld support,Make sure that the comment is aligned:[ --enable-my_helloworld Enable my_helloworld support])
编译扩展
cd my_helloworld/path/to/php/bin/phpizeConfiguring for:PHP Api Version: 20160303Zend Module Api No: 20160303Zend Extension Api No: 320160303./configure --enable-my_helloworld --with-php-config=/path/to/php/bin/php-configmake && make install
测试扩展
修改php.ini文件,添加一行记录
extension=my_helloworld.so
测试安装结果
path/to/bin/php my_helloworld.phpFunctions available in the test extension:confirm_my_helloworld_compiledCongratulations! You have successfully modified ext/my_helloworld/config.m4. Module my_helloworld is now compiled into PHP.
测试加载模块
path/to/bin/php -m[PHP Modules]Coredatemy_helloworldpcreReflectionSPLstandard[Zend Modules]
阅读全文
0 0
- php 创建一个扩展开发环境的正确姿势
- Linux下躺着搭建nodejs开发环境的正确姿势
- ThinkPHP5开发的正确姿势
- 开发接口的正确姿势
- ThinkPHP5开发的正确姿势
- 扩展js原生对象的正确姿势
- PHP扩展开发之创建一个类
- Genymotion创建模拟器的正确姿势
- win8搭建kubernetes环境的正确姿势
- PHP中正确使用Json的姿势
- PHP Composer 的正确使用姿势
- 新手看php手册的正确姿势
- 将一个双向链表逆置的正确姿势
- 入门TrafficServer插件开发的正确姿势
- AndroidStudio2.2开发NDK的正确姿势
- AndroidStudio2.2开发NDK的正确姿势
- Python开发游戏的正确姿势
- PHP扩展开发-创建扩展
- 【vue+axios】一个项目学会前端实现登录拦截
- 移植ubuntu14.04根文件系统至beaglebone开发板探索
- 1216: 找零钱
- Android开发中Handler的经典总结
- 文章标题
- php 创建一个扩展开发环境的正确姿势
- CNN各个层的介绍
- 获取ip地址
- .net 经常抛出OutOfMemoryException 服务器环境问题
- Linux kernel轮询与等待队列
- application/json 和 application/x-www-form-urlencoded的区别
- c++:explicit 抑制构造函数隐式转换
- 量化交易中VWAP/TWAP算法的基本原理和简单源码实现(C++和python)
- QT中UDPSocket丢包问题(续)