vim + Xdebug を使用して remote debug

Xdebug をインストール中にハマって検索を掛けて問題を解決しようとしたら、別の面白そうなことが載ってた。

Xdebug の設定

  7 ;[remote]
  8 xdebug.remote_enable = 1
  9 xdebug.remote_port = 9000
 10 xdebug.remote_host = localhost
 11 xdebug.remote_handler = dbgp

xdebug の設定追加

vim のプラグインをインストールする

http://www.vim.org/scripts/script.php?script_id=1929

DLした zip ファイルを解凍
unzip debugger.zip
plugin の設置

解凍後作成されたplugin ディレクトリをホームディレクトリ上の.vimディレクトリに移動

以上!

試してみる

vim を起動後F5を押すとこんな風にリクエスト待ち表示が出る

waiting for a new connection on port 9000 for 5 seconds...

リクエストを送る
http://hoge.com/hogehoge.php?XDEBUG_SESSION_START=1

対象ページURL + ?XDEBUG_SESSION_START=1 を vim のリクエスト待ち受け中に読み込む

f:id:riceplanting:20131004010050j:plain

使い方を覚えれば便利そうだなーと思ったりらじばんだり。

時間があればこっちもやってみたい

参考:Vim + Vdebug + Xdebug でPHPのリモートデバッグ | Code Life

こっちの方が、ショートカットも多くて使いやすそうかな?