VIM+Xdebug調試php
1.安裝Xdebug
sudo apt-get install php5-xdebug
2.配置Xdebug
編輯/etc/php5/apache2/conf.d/xdebug.ini,加入
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = localhost
3.安裝vim外掛程式DBGp
下載頁面: http://www.vim.org/scripts/script.php?script_id=1929
下載後放入plugins目錄中即可。
4.在瀏覽器中開啟要調試的php頁面,在URL後加上?XDEBUG_SESSION_START=1參數
用vim開啟此檔案,用:Bp 設定斷點,然後安 F5 鍵,vi會提示 waiting for a new connection on port 9000 for 5 seconds… ,此時在5秒內重新整理剛才那個頁面,即可在vim中看到調試介面。
如果出現 , AttributeError("DbgProtocol instance has no attribute 'stop'", 則說明沒有配置成功,要麼是 xdebug.remote_* 沒有配置好,要麼是url尾部上沒有加入 ?XDEBUG_SESSION_START=1 ,要麼是你沒有在5秒內重新整理頁面 .
5.在擷取變數內容時,如果變數為 array ,那麼預設只會顯出 (array) ,而不會顯示數組內的各元素,如果無法顯示數組元素內容,那麼調試會遇到很多問題,因此可以根據 debugger.vim 中的注釋,自行在 .vimrc 中加上如下一行:
let g:debuggerMaxDepth = 5
更多的配置,可以依次類推,都在debugger.vim中有所說明。
轉自http://lds2008.blogbus.com/logs/115127244.html