最後更新: 2015-05-15
HomePage:
http://www.xdebug.org
Centos6 Package:
php-pecl-xdebug.i686 2.1.4-2.el6
Configure:
/etc/php.d/xdebug.ini
# Default value: 1 # Load 這 module 入去 apache xdebug.default_enable=1
設定
Trace
; When this setting is set to on, the tracing of function calls will be enabled ; just before the script is run. This makes it possible to trace code in the ; auto_prepend_file [1]. xdebug.auto_trace=1
每次 Call 都會建立 trace.*.xt
Profiler
# Default value: 0
# creates files in the profile output directory(xdebug.profiler_output_dir)
# Those files can be read by KCacheGrind to visualize your data.
xdebug.profiler_enable=0
# selectively enable the profiler
# XDEBUG_PROFILE GET/POST/cookie parameter
xdebug.profiler_enable_trigger=1
# Default value: /tmp
# Output debug info 到那目錄
xdebug.profiler_output_dir=/tmp
Usage
Call
curl http://DOMAIN/?XDEBUG_PROFILE
就會有
/tmp/cachegrind.out.PID
Web GUI
implements a subset of the features of kcachegrind
Window GUI viewer
WinCacheGrind
It is a viewer for cachegrind.out files generated by xdebug 2.
HP: https://ceefour.github.io/wincachegrind/
DL: https://github.com/ceefour/wincachegrind/releases/download/1.1/wincacheg...
kcachegrind
Homepage: http://kcachegrind.sourceforge.net/html/Home.html
Usage
The second column "Self" shows the time spend in this function (without its children),
The third column "Called" shows how often a specific function was called and
The last column "Function" shows the name of the function.
Xdebug changes internal PHP function names by prefixing the function name with "php::"
qcachegrind
The QCacheGrind branch of KCacheGrind compiled with the QT5 toolkit for use in Windows.
進階設定
trigger by GET()
trigger the generation of profiler files by using the XDEBUG_PROFILE GET/POST parameter with value "profiler_enable_trigger_value"
# In order to prevent the profiler to generate profile files for each request, you need to set xdebug.profiler_enable to 0.
xdebug.profiler_enable_trigger=1
# Default value: ""
xdebug.profiler_enable_trigger_value=8888
# 指定 output 名及 output 地方
xdebug.profiler_output_dir=/home/vhosts/xxx/public_html/xdebug
xdebug.profiler_output_name=callgrind.out.%H
%s script name (cachegrind.out._home_httpd_html_test_xdebug_test_php)
%H $_SERVER['HTTP_HOST']
Usage Example:
http://x.y/?XDEBUG_PROFILE=8888
DOC
http://www.xdebug.org/docs/