PHPStorm下XDebug配置

 

1安裝Xdebug

用yum安裝可能會失敗,用pecl安裝成功。

#yum installphp-pecl-xdebug.x86_64

pecl installxdebug
         如果pecl命令不存在請先安裝PHP-pear
         命令:yum install php-pear

注意多加了一項IDE Key,且要與後面PHPStorm中的配置相同:

zend_extension=/path/xdebug.so

zend_debugger.allow_hosts=10.25.1.199

zend_debugger.expose_remotely=always

zend_debugger.httpd_uid=-1

xdebug.auto_trace = on

xdebug.auto_profile = on

xdebug.collect_params = on

xdebug.collect_return = on

xdebug.profiler_enable = on

xdebug.trace_output_dir = “/tmp”

xdebug.profiler_output_dir =”/tmp”

xdebug.dump.GET = *

xdebug.dump.POST = *

xdebug.dump.COOKIE = *

xdebug.dump.SESSION = *

xdebug.var_display_max_data = 4056

xdebug.var_display_max_depth = 5

xdebug.remote_enable=on       

xdebug.remote_handler=dbgp

xdebug.remote_host=10.25.1.199

xdebug.remote_port=9010

xdebug.remote_autostart=1

xdebug.idekey=”PHPSTORM”

 

2配置PHPStorm


圖1:首先配置PHP解釋器的路徑

 


圖2:File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息,name填localhost,host填localhost,port填80,debugger選XDebug

 


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

 


圖4:進入File>Settings>PHP>Debug>DBGpProxy,IDE key填PHPSTORM,host填localhost,port 填80

 


圖5:在phpStorm裏打開監聽,就是一個電話一樣的按鈕

 


圖6:在瀏覽器裏打開XDebug工具,訪問localhost,與phpStorm連接成功!

 

3常見問題

訪問頁面準備進入斷點時,PHPStorm報錯:Cannot accept external Xdebug connection: Cannot evaluate expression’isset($_SERVER[‘PHP_IDE_CONFIG’])’;

 

導致此問題的一個可能原因是:服務器端的php.ini中配置了:

         extension=/path/xdebug.so

應該只保留下面一個:

         zend_extension=/path/xdebug.so

 

參考資料

1 phpStorm+XDebug進行斷點調試的配置

http://www.chenxuanyi.cn/xampp-phpstorm-xdebug.html

 

2利用下面網頁中的Start debug按鈕在COOKIE中設置Xdebug所需的變量。

http://www.jetbrains.com/phpstorm/marklets/

 

3 Cannot accept external Xdebug connection:Cannot evaluate expression ‘isset($_SERVER[‘PHP_IDE_CONFIG’])

http://devnet.jetbrains.com/message/5463083?tstart=0

document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
發佈了3 篇原創文章 · 獲贊 3 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章