1. 程式人生 > >在Intellij IDEA下用X-debug調試PHP

在Intellij IDEA下用X-debug調試PHP

lec out com dll PE org 註意 2.6.0 輸入

用Intellij IDEA使用X-debug來調試PHP,主要需要配置的部分有三個地方,分別為php.ini的配置,IDEA的配置和瀏覽器的配置,主要如下:

php.ini(wamp修改的是phpForApache.ini)的主要配置如下所示,關鍵參數根據實際情況可以修改:

xdebug 下載地址: https://xdebug.org/download.php

技術分享圖片

[Xdebug]
zend_extension_ts=”d:/wamp/bin/php/php7.1.16/zend_ext/php_xdebug-2.6.0-7.1-vc14-x86_64.dll”
#如果不是ts版本請用zend_extension=
#host值最好用當前用到的域名或者127.0.0.1 xdebug.remote_host=abc.com xdebug.remote_port = 9000 xdebug.remote_mode = "req" xdebug.remote_enable = on xdebug.remote_handler = dbgp #key 值可以是任意值 xdebug.idekey = "xdebug_info" xdebug.profiler_enable=on #沒有就新建這個目錄 xdebug.trace_output_dir=”d:/wamp/bin/php/debug” xdebug.profiler_output_dir=”d:/wamp/bin/php/debug” xdebug.auto_trace=on xdebug.collect_params=on xdebug.collect_return=on xdebug.show_exception_trace = On xdebug.remote_autostart = On xdebug.collect_vars = On

配置好了,在CMD裏面輸入

php -m

如果能看到XDebug模塊,說明開啟成功。

*: 值得註意的是,這裏需要確定好XDebug和PHP的對應版本

IDEA的配置如下:
進入File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息,name填要調試的主機名 (如:abc.com或者localhost等),host填(如:localhost或者abc.com等),port填 80,debugger選XDebug

技術分享圖片

進入File>Settings>PHP>Debug,看到XDebug選項卡,port填9000,其他默認

技術分享圖片

進入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 xdebug_info,host 填abc.com,port 填80

和php.ini的IDE_key要保持一致哦。。。。。、

技術分享圖片

最好有空可以建一個remote_debug檢查一下

技術分享圖片

最後就是瀏覽器設置了我下載的是xdebug Helper

技術分享圖片

在Intellij IDEA下用X-debug調試PHP