摘要:操作系統(tǒng),請自己嘗試目標使用搭建擴展開發(fā)調(diào)試環(huán)境調(diào)試目標執(zhí)行程序腳本里使用擴展里的函數(shù)等,代碼里面開始喚起單步調(diào)試,步驟簡潔開發(fā)工具能夠識別各種文件格式能處理好的引用現(xiàn)代提供的功能,搜索,跳轉(zhuǎn),終端,等背景調(diào)試比較繁瑣嘗試過從源碼編譯找
操作系統(tǒng):deepin(debain),ubuntu(請自己嘗試) 目標:使用qtcreator,搭建php擴展開發(fā)、調(diào)試環(huán)境
調(diào)試目標:執(zhí)行php程序(php腳本里使用擴展里的函數(shù)等),c代碼里面開始喚起單步調(diào)試,步驟簡潔
c開發(fā)工具:能夠識別各種文件格式(m4,makefile),能處理好include的引用
現(xiàn)代IDE提供的功能,搜索,跳轉(zhuǎn),終端,git等
背景:gdb調(diào)試比較繁瑣
嘗試過clion, eclipse, atom, vscode, qtcreator
apt-get install build-essential #找個自己喜歡的目錄(要有權(quán)限奧) git clone https://github.com/php/php-src.git cd 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 --ini php -dextension=json.so -m mkdir /etc/php.d echo "extension=json.so" > /etc/php.d/json.ini php -m開發(fā)php擴展,請參考擴展開發(fā)文章?。╯um)
cd ext ./ext_skel --extname=sum cd sum
修改以下文件
config.m4
dnl $Id$ dnl config.m4 for extension sum dnl Comments in this file start with the string "dnl". dnl Remove where necessary. This file will not work dnl 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 ./configure make make install echo "extension=sum.so" > /etc/php.d/sum.ini查看擴展功能
test.php
php test.php
會輸出 int(20)
配置qt creator開發(fā)環(huán)境菜單欄:文件->新建文件或項目->導入現(xiàn)有項目
項目名稱:php-src, 位置為php源碼編譯目錄
默認
默認
構(gòu)建配置:
補充:
清除步驟:
解決擴展引用頭文件問題,添加"."
運行配置:
f5調(diào)試走起:
約定學習他人擴展約定:
參考
把別人的擴展放到ext目錄下,按圖片修改下內(nèi)容,按以上步驟調(diào)試PHP Extension Development for Beginners with Joe Watkins
(https://www.youtube.com/watch...)
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/23092.html
摘要:作者逆向驛站微信公眾號逆向驛站知乎逆向驛站一款開發(fā)的國外軟件,大概率是沒有做中文支持的,所以你漢化中,不論怎么設置編碼都一定是亂碼。 作者:逆向驛站微信公眾號:逆向驛站知乎:逆向驛站showImg(https://segmentfault.com/img/bVbnE98?w=1100&h=731); 一款QT開發(fā)的國外軟件,大概率是沒有做中文支持的,所以你漢化中,不論怎么設置編碼都一定...
摘要:友情提示先關(guān)注收藏,再查看,萬字保姆級語言從入門到精通教程。及大牛出天地開始有隨之乃有萬種語年英國劍橋大學推出了語言。 友情提示:先關(guān)注收藏,再查看,13 萬字保...
摘要:原文地址在新手學堂里面,我們將從零基于開發(fā)一個簡單的擴展,這個擴展的名字叫做現(xiàn)在我們著手準備開發(fā)需要的環(huán)境吧。 原文地址: http://www.zendapi.org/manual... 在新手學堂里面,我們將從零基于 zendAPI 開發(fā)一個簡單的 PHP 擴展,這個擴展的名字叫做 hellozapi , 現(xiàn)在我們著手準備開發(fā)需要的環(huán)境吧。 demo 的項目庫地址 https://...
閱讀 2984·2023-04-26 01:49
閱讀 2106·2021-10-13 09:39
閱讀 2322·2021-10-11 11:09
閱讀 951·2019-08-30 15:53
閱讀 2844·2019-08-30 15:44
閱讀 950·2019-08-30 11:12
閱讀 3023·2019-08-29 17:17
閱讀 2407·2019-08-29 16:57