Xdebug是php的一款调试工具,是基于zend的一个扩展,能够用来跟踪,调试和分析PHP程序的运行情况。如变量,函数调试,性能监测,代码覆盖率等php
1.下载xdebug源程序linux
git clone git://github.com/xdebug/xdebug.git https://xdebug.org/download.php#releases
2.解压xdebug包
tar -xzvf xdebug.tgz
git
3.进入解压目录
cd xdebug
github
4.运行phpize
/usr/local/php/bin/phpize
web
5.编译
./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
安全
6.安装
make && make install
函数
7.安装成功后会在php扩展目录生成相似xdebug.so的扩展工具
8.安装xdebug客户端xdebugclient (须要libedit扩展)性能
cd debugclient ./configure --with-libedit make make install
1.在php.ini配置文件中添加以下内容
zend_extension="/wherever/you/put/it/xdebug.so"
2.若是是php5.3以前版本线程安全,添加以下内容代替上面1的内容
zend_extension_ts="/wherever/you/put/it/xdebug.so"
3.自从php5.3以后zend_extension_ts, zend_extension_debug再也不使用.net
4.xdebug的一些其余配置
;显示错误信息 xdebug.default_enable = 1 ;函数调试 xdebug.auto_trace=on xdebug.trace_output_dir xdebug.trace_output_name ;Type: string, Default value: trace.%c xdebug.collect_params = 1|3|4 (参数长度,参数值,参数=值) xdebug.show_mem_delta=1 显示内存 xdebug.collect_return=1 显示返回值 xdebug.trace_options =1 追加日志 xdebug.collect_params=1 xdebug.collect_vars = 1 ;开启性能分析 xdebug.profiler_enable=1 ;性能分析日志保存目录 xdebug.profiler_output_dir = /data/logs/xdebug/ ;性能分析日志文件名称 xdebug.profiler_output_name = cachegrind.out.log ;默认是以下格式,t时间,p进程id ;xdebug.profiler_output_name = cachegrind.out.%t.%p ;代码覆盖率 xdebug.coverage_enable = 1 ;如下是远程调试配置 xdebug.remote_host= 127.0.0.1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9000 xdebug.remote_log="/data/logs/xdebug/xdebug.log"
4.重启php使配置生效
1.linux平台
工具KCacheGrind (Linux, KDE) https://kcachegrind.github.io/
2.win平台查看工具WinCacheGrind
相关网址
http://ceefour.github.io/wincachegrind/ https://sourceforge.net/projects/wincachegrind/ https://github.com/ceefour/wincachegrind/releases/tag/1.1
列名称含义
Self - Shows the execution time of the code in the current block
Cum. - Shows the total exuction time of functions that the current function (Self) calls
Avg vs. Total: Average is average time per call, Total is the total time spend in all calls.
3.Web方式查看webgrind
https://github.com/jokkedk/webgrind