環境
我的環境是Eclipse for php+nginx+xdebug。
工具
具體步驟
1. 安裝Xdebug
- 把下載好的xdebug檔案放在php的ext目錄下。
在PHP檔案夾裡面找到php.ini,在這個檔案的最後面加入如下配置資訊:
【PS:“;”開頭的語句為備註陳述式。我的xdebug版本為php_xdebug-2.4.0rc3-5.6-vc11.dll】
zend_extension = F:\DevEnv\PHP\ext\php_xdebug-2.4.0rc3-5.6-vc11.dll;zend_extension_ts = F:\DevEnv\PHP\ext\php_xdebug-2.4.0rc3-5.6-vc11.dll;extension = php_xdebug-2.4.0rc3-5.6-vc11.dll[Xdebug]xdebug.auto_trace = Onxdebug.show_exception_trace = Onxdebug.remote_autostart = Onxdebug.remote_enable = Onxdebug.collect_vars = Onxdebug.collect_return = Onxdebug.collect_params = Onxdebug.trace_output_dir=”D:/xDebugLog”xdebug.profiler_output_dir=”D:/xDebugLog”xdebug.profiler_enable=Onxdebug.remote_host=localhostxdebug.remote_port=9000xdebug.remote_handler=dbgp
- 修改好後啟動nginx與php。【PS:php本來已經啟動的話要重新啟動,因為修改了配置。】
2. 配置Eclipse
- 在Eclipse裡開啟項目,在項目的Properties裡面找到”PHP Debug”進行配置。
- PHP Server我們選擇建立一個。
最後剩下的Path Mapping可以不改。
選Finish,可以看到修改好的php server了。
OK,回到Properties介面,選擇剛剛建立的php-test。
OK,php debug修改完。
最後還要配置一下Run->Debug Configurations。
所有配置完畢!
最後在Eclipse裡測試一下:
如果沒問題Eclipse會自動進入debug模式。
PS:也可以在瀏覽器輸入網址訪問,這時如果你的eclipse是開啟的,而且php.ini的xdebug開啟了,配置也沒問題的話也是會進入eclipse的debug狀態的。
好了,大家慢慢享受單步調試的樂趣吧哈哈哈~~~
參考文章:
Eclipse for php + Xdebug搭建PHP的調試環境
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了Eclipse for php+Xdebug,搭建php單步調試環境,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。