はい!OpenPNE3をXdebugでステップ実行とかする方法!の巻!


はい!ギュンばんわ!

みなさんデバッガ使ってますか?
OpenPNE3ってOpenPNE2よりソースが複雑になってて、デバッガとか使ってソースの挙動追いたくないすか?

ということでOpenPNE3をXdebugでステップ実行する方法を書きますよと。

Xdebugのインストール
pecl install xdebug-beta

PHPの設定
/etc/php.d/xdebug.ini
を、

zend_extension=/usr/lib64/php/modules/xdebug.so

[debug]
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32

vimのpluginの設定
wget http://www.vim.org/scripts/download_script.php?src_id=7285

unzip debugger.zip
cp plugin/* ~/.vim/plugin/

firefoxのAdd-onの用意
https://addons.mozilla.org/ja/firefox/addon/easy-xdebug/
をインストール

■使い方
1) 最初からステップ実行
vimを開いてF5で待機
firefoxの右下の「Start xdebug session」を押して、OpenPNE3にアクセス
vim上でデバッガが開くので、F2とかF3とかF11とかctrl+wとかでいろいろ見てく

2) ブレークポイントいれてみる
例えば、 vim lib/user/opSecurityUser.class.php とか開いて、「:Bp」ってどこかの行で打ってブレークポイントを入れる
その状態でF5
firefoxの右下の「Start xdebug session」を押して、OpenPNE3にアクセス
vim上でF5でrunすると、ブレークポイントの位置まで飛ぶ

■よく使う操作
F1: resize
F2: step into(関数の中にどんどん入ってく)
F3: step over(関数の中には入らない)
F4: step out(関数の外に出る)
F5: run
F6: quit debugging
F11: get all context
F12: get property at cursor

Ctrl-w [+-](Windowの幅を広げる。WATCH_WINDOWでCtrl-w 40+とかやると良い感じ)

■どすか?
どすか?