print_r
、 log
、 var_dump
這類一次調試一行的方式PhpStorm
中配置過前端
頁面 按菜單或按鈕 調用 API
時,斷點調試後端代碼Postman
訪問 API 時,斷點調試後端代碼如何愉快的在PhpStorm中進行Xdebug斷點調試: https://blog.csdn.net/RobotYa...
如何愉快的在PhpStorm中進行Xdebug斷點調試: https://segmentfault.com/a/11...
PHP xdebug 模塊下載: https://xdebug.org/download.php
PHP xdebug 模塊檢測和下載: https://xdebug.org/wizard.php
Xdebug helper 瀏覽器插件: https://www.crx4chrome.com/cr...
PhpStorm 本地斷點調試: https://blog.csdn.net/qq_2138...
Wamp3.1.0_x64
,已經默認安裝了 php_xdebug
php_xdebug
啓用便可 phpstorm
提示 xdebug版本與php版本不符,則須要自行下載 xdebug php -r 'phpinfo();'
,複製終端輸出的全部 phpinfo 信息phpinfo
,並下載對應 xdebug
版本 查看 php.ini
的 xdebug
配置,確保 xdebug.remote_enable = On
啓用php
; XDEBUG Extension [xdebug] zend_extension ="C:/Users/robot/Program/Wamp/Wamp3.1.0_64/bin/php/php5.6.31/zend_ext/php_xdebug-2.5.5-5.6-vc11-x86_64.dll" xdebug.remote_enable = On xdebug.profiler_enable = off xdebug.profiler_enable_trigger = off xdebug.profiler_output_name = cachegrind.out.%t.%p xdebug.profiler_output_dir ="C:/Users/robot/Program/Wamp/Wamp3.1.0_64/tmp" xdebug.show_local_vars=0
參考文檔html
下載 xdebug.tgz 安裝包前端
參考文檔node
安裝 xdebug 模塊chrome
sudo apt-get install php-xdebug
查看全部模塊express
php -m
查找 xdebug 安裝後的擴展路徑apache
find /usr/ -name 'xdebug.so'
/usr/lib/php/20151012/xdebug.so
查找 php.ini 所在路徑segmentfault
php -i|grep 'php.ini'
或 php -r 'phpinfo();'
/etc/php/7.0/cli/php.ini
或 /etc/php/7.0/apache2/php.ini
[xdebug] zend_extension="/usr/lib/php/20151012/xdebug.so" xdebug.remote_enable=1 //xdebug.remote_handler=dbgp //xdebug.remote_mode=req //xdebug.remote_host=127.0.0.1 //xdebug.remote_port=9000
搜索關鍵詞 debug,選擇 Languages & Frameworks 下的 PHP -> Debug後端
端口 9000
多種調試配置方式:本質都是在 cookie
中自動添加 XDEBUG_SESSION=PHPSTORM
api
瀏覽器
Xdebug Helper
插件設置 idekey
,用 debug 啓動訪問時,而後 cookie 會自動添加 XDEBUG_SESSION
使用 請求體 request
中設置 XDEBUG_SESSION_START=PHPSTORM
請求參數,而後 cookie 會自動添加 XDEBUG_SESSION
URL
後追加,如 http://localhost:500/api/TestQ/xdebug?XDEBUG_SESSION_START=PHPSTORM
body
中追加,如 request.body.XDEBUG_SESSION_START=PHPSTORM
PhpStorm
配置 Debug Configuration 與 Servers
,用 PhpStorm debug 啓動訪問時,URL會自動追加 XDEBUG_SESSION_START 請求參數
,而後 cookie 會自動添加 XDEBUG_SESSION
優勢:
只要配置一致的 idekey=PHPSTORM
或在 cookie 中添加 XDEBUG_SESSION=PHPSTORM
Xdebug Helper
配置 idekey=PHPSTORM
後,在啓用 debug 模式時,會自動在當前訪問 url 所在域名(如 localhost:500)下的 cookie 中添加 XDEBUG_SESSION=PHPSTORM
前端
只須要任意頁面啓用 Xdebug Helper 的 debug 模式便可,原理如上(但要確認你的 client request 攜帶的 cookie 能夠正確到達 server requestPostman
只須要指定域名(如 localhost)的 cookie
中添加一次 XDEBUG_SESSION=PHPSTORM
便可PhpStorm
中只需開啓 Listening Debug Connections
(就是頂部路徑欄中右邊那個小電話
圖標)缺點:
Xdebug helper
插件的 crx
文件,在瀏覽器擴展程序中拖放安裝便可idekey
以下 PhpStorm
小電話
debug 模式
) Postman URL
cookie
中添加一次 XDEBUG_SESSION=PHPSTORM
前端 node.js / express.js 等
XDEBUG_SESSION=PHPSTORM
,如 response.cookie('XDEBUG_SESSION', 'PHPSTORM');
node.js + express.js
直接在 app.js
中全局注入了 XDEBUG_SESSION 的 cookie 優勢:
缺點:
XDEBUG_SESSION_START=PHPSTORM
請求參數PhpStorm
瀏覽器 URL / 前端 URL
Disable 模式
;或者直接卸載?XDEBUG_SESSION_START=PHPSTORM
Postman URL
?XDEBUG_SESSION_START=PHPSTORM
前端 node.js / express.js 等
XDEBUG_SESSION=PHPSTORM
,如 request.body.XDEBUG_SESSION_START='PHPSTORM'
Debug Configuration 與 Servers
方式優勢:
XDEBUG_SESSION_START=PHPSTORM
請求參數缺點:
PhpStorm
中配置 Debug Configuration 與 Servers甲殼蟲
圖標,獲取調試用的 XDEBUG_SESSION_START=session_key
PhpStorm
中配置 Debug Configuration 與 ServersEdit Configurations
+ 號
,新增一個 PHP Web Page...
,先新建一個 Web 服務 甲殼蟲
圖標,獲取調試用的 XDEBUG_SESSION_START=session_key
XDEBUG_SESSION_START=12850
,以後就是和《請求體 request 中經過 XDEBUG_SESSION_START 請求參數 方式》介紹的操做同樣啦,這裏再也不贅述。PHP
安裝Xdebug
模塊,在 正確的 php.ini
下設置 xdebug.remote_enable=1
或者 On
Postman
在 API 域名下的cookie
中添加XDEBUG_SESSION=PHPSTORM
PhpStorm
啓動小電話
,開啓偵聽