Xdebugを使う
phpのデバッグにXdebugを使うようにした.環境はFreeBSD7.0-RELEASE.以下導入メモ.Xdebugをportsからインストール.
# cd /usr/ports/devel/php-xdebug # make install ***************************************************************************** The php debugger 'xdebug' has been installed successful. Add a line containing extension=/usr/local/lib/php/20060613/xdebug.so or zend_extension=/usr/local/lib/php/20060613/xdebug.so to your php.ini to load it. xdebug is not compatible with the extension 'Zend Optimizer' - you're only able to use one of them. So take care having at least the lesser required extension disabled by commenting out it's loader line in your php.ini. Add following section to enable profiling: xdebug.profiler_enable = 1 xdebug.profiler_output_dir = /tmp/profiler ***************************************************************************** ===> Registering installation for php-xdebug-2.0.2
zend_extension=/usr/local/lib/php/20060613/xdebug.so
apacheを再起動するなりするとXdebugが使用可能となるはず.
$ php -m (省略) [Zend Modules] Xdebug
Zend Modules に XdebugがあればOK*2.
プロファイラの設定
# vi /usr/local/etc/php.ini // 以下を記述 xdebug.profiler_enable=1 xdebug.profiler_output_dir = "/var/log/xdebug/" // ログを吐き出させたい場所.
# mkdir /var/log/xdebug # chown www /var/log/xdebug # apachectl restart
吐き出されるログはそのまんまだと見難いため,WinCacheGrindやKcacheGrindIndexで閲覧する.