php 创建一个扩展开发环境的正确姿势
2017-06-01 12:13
645 查看
安装编译PHP
官网下载最新php-7.1.5.tar的源码包设置开发目录,打开调试模式,禁止其他内置模块
cd path/to/php-src ./configure --prefix=path/to/php --enable-debug --disable-all make && make install
生成PHP扩展目录
cd php-src/ext ./ext_skel --extname=my_helloworld Creating directory my_helloworld Creating 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.m4 3. $ ./buildconf 4. $ ./configure --[with|enable]-my_helloworld 5. $ make 6. $ ./sapi/cli/php -f ext/my_helloworld/my_helloworld.php 7. $ vi ext/my_helloworld/my_helloworld.c 8. $ make Repeat steps 3-6 until you are satisfied with ext/my_helloworld/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.
编辑扩展文件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/phpize Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303 ./configure --enable-my_helloworld --with-php-config=/path/to/php/bin/php-config make && make install
测试扩展
修改php.ini文件,添加一行记录
extension=my_helloworld.so
测试安装结果
path/to/bin/php my_helloworld.php Functions available in the test extension: confirm_my_helloworld_compiled Congratulations! You have successfully modified ext/my_helloworld/config.m4. Module my_helloworld is now compiled into PHP.
测试加载模块
path/to/bin/php -m[PHP Modules]
Core
date
my_helloworld
pcre
Reflection
SPL
standard
[Zend Modules]
相关文章推荐
- PHP扩展开发之创建一个类
- 创建一个php本地开发环境需要……
- 快速开发一个PHP扩展
- 快速开发一个PHP扩展
- Ubuntu下配置一个高效的PHP开发环境GVIM
- 详解如何正确配置PHP开发环境
- 快速开发一个PHP扩展
- 快速开发一个PHP扩展图文教程
- 开发PHP扩展-提供一个可以被PHP使用的类
- 搭建Python的Eclipse开发环境之创建一个新项目
- 在vs2008开发PHP扩展之一--基础环境搭建
- 配置一个高效的PHP开发环境Vim
- Alex学PHP [配一个开发环境]
- 快速开发一个PHP扩展图文教程
- 在Windows环境下进行PHP扩展的开发
- Moblin v2开发环境设置——创建一个新应用程序
- 一个简单php扩展介绍与开发教程
- 一个简单php扩展介绍与开发教程
- 在vs2008开发PHP扩展之三--环境搭建常见问题列表。
- 详解正确配置PHP开发环境