用qt creator搭建开发、调试php扩展的环境
来源:互联网 发布:windows xp msdn iso 编辑:程序博客网 时间:2024/05/20 03:41
https://segmentfault.com/a/1190000009828172
目标:使用qtcreator,搭建php扩展开发、调试环境
调试目标:执行php程序(php脚本里使用扩展里的函数等),c代码里面开始唤起单步调试,步骤简洁
c开发工具:能够识别各种文件格式(m4,makefile),能处理好include的引用
现代IDE提供的功能,搜索,跳转,终端,git等
背景:
gdb调试比较繁琐
尝试过clion, eclipse, atom, vscode, qtcreator
从源码编译php
apt-get install build-essential#找个自己喜欢的目录(要有权限奥)git clone https://github.com/php/php-src.gitcd php-src./configure --help./buildconf --force./configure --disable-all --prefix=/usr --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d --enable-ctype --enable-json=shared make -j$(cat /proc/cpuinfo |grep "processor"|wc -l) ./sapi/cli/php -v make install php -v php -m php --iniphp -dextension=json.so -mmkdir /etc/php.decho "extension=json.so" > /etc/php.d/json.iniphp -m
开发php扩展,请参考扩展开发文章 (sum)
cd ext./ext_skel --extname=sumcd sum
修改以下文件 config.m4
dnl $Id$dnl config.m4 for extension sumdnl Comments in this file start with the string 'dnl'.dnl Remove where necessary. This file will not workdnl without editing.dnl If your extension references something external, use with:PHP_ARG_WITH(sum, for sum support,[ --with-sum Include sum support])if test "$PHP_SUM" != "no"; then PHP_NEW_EXTENSION(sum, sum.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)fi
sum.c
PHP_FUNCTION(sum){ zval *input; zval *item; int32_t total=0; HashPosition position; if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &input) == FAILURE) { return; } for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &position); (item = zend_hash_get_current_data_ex(Z_ARRVAL_P(input), &position)); zend_hash_move_forward_ex(Z_ARRVAL_P(input),&position) ){ if(Z_TYPE_P(item) == IS_LONG){ total += Z_LVAL_P(item); }else zend_throw_exception(NULL, "oh dear!", 0); } RETURN_LONG(total);}
安装扩展
phpize./configuremakemake installecho "extension=sum.so" > /etc/php.d/sum.ini
查看扩展功能
test.php
<?php$a = sum([1,2,3,4,10]);var_dump($a);
php test.php
会输出 int(20)
配置qt creator开发环境
菜单栏:文件->新建文件或项目->导入现有项目
项目名称:php-src, 位置为php源码编译目录
默认
默认
构建配置:
补充:
清除步骤:
解决扩展引用头文件问题,添加"."
运行配置:
f5调试走起:
约定
学习他人扩展约定:把别人的扩展放到ext目录下,按图片修改下内容,按以上步骤调试
参考
PHP Extension Development for Beginners with Joe Watkins
(https://www.youtube.com/watch...)
阅读全文
0 0
- 用qt creator搭建开发、调试php扩展的环境
- 用QtCreator搭建PHP扩展开发的编辑环境和调试环境
- Qt+VS2008+Qt Creator开发环境搭建
- 基于ARM的Qt Creator嵌入式开发环境搭建
- Fedora9 下搭建Qt Creator的ARM开发环境
- Fedora9 下搭建Qt Creator的ARM开发环境
- Qt Creator 下 android 开发环境的搭建
- 基于ARM的Qt Creator嵌入式开发环境搭建
- qt+creator 轻松搭建cocos2dx开发环境
- Qt Creator 搭建嵌入式开发环境
- 搭建psoc creator开发环境调试软件
- QT Creator 环境搭建
- Mac下用Qt Creator开发Android的环境搭建(图文教程)
- Qt(SDK) + VS2008 + Qt Creator开发环境搭建
- OS X 10.9 QT/QT Creator 开发调试环境的设置
- qt的环境搭建(二)Qt Creator
- 【Qt】Qt环境搭建(Qt Creator)【转】
- ubuntu 9.1 下搭建Qt Creator的ARM开发环境(1)
- 关于HomeDey中涉及隐私相关
- SSD 之wl(wear leveling)算法分析
- 安装SQL SERVER 2008 R2 错误提示
- spark集群环境配置
- 将包含jar包的java项目打成jar包
- 用qt creator搭建开发、调试php扩展的环境
- annotation-driven,annotation-config,component-scan的区别与作用(转)
- 使用Jenkins进行持续构建与发布应用到Kubernetes集群中
- eclipse 自动生成注释 @author
- 6月28日,来香港的第三天
- 使用bochs调试grub2
- Fragment 跳转到 Activity 如何接收回来的数据
- (转)知乎:维度灾难
- mapreduce和shuffle详解