xdebug配置

2017/01/02 php

基本特征 Basic Features

xdebug.default_enable = 1显示错误信息

1、性能分析 Profiling PHP Scripts in php.ini

开启性能分析: xdebug.profiler_enable setting = 1
日志文件输出目录: xdebug.profiler_output_dir = /data/log 通常是类似的文件 cachegrind.out.%p cachegrind.out.%t.%p

日志文件名:xdebug.profiler_output_name

xdebug.profiler_enable_trigger

You can also selectively enable the profiler with the xdebug.profiler_enable_trigger setting set to 1. If it is set to 1, then you can enable the profiler by using a GET/POST or COOKIE variable of the name XDEBUG_PROFILE. The FireFox 2 extension that can be used to enable the debugger (see HTTP Debug Sessions) can also be used with this setting. In order for the trigger to work properly, xdebug.profiler_enable needs to be set to 0.

函数:获取日志文件名 string xdebug_get_profiler_filename()

性能日志分析工具

linux平台

1)、工具KCacheGrind (Linux, KDE) https://kcachegrind.github.io/

win平台查看工具

2)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方式查看

https://github.com/jokkedk/webgrind

2、代码覆盖率分析 Code Coverage Analysis

xdebug.coverage_enable = 1

函数检查是否开启 boolean xdebug_code_coverage_started() Returns whether code coverage is active.

Example:

<?php var_dump(xdebug_code_coverage_started());

xdebug_start_code_coverage();

var_dump(xdebug_code_coverage_started()); ?> 

3、函数调试 Function Traces

xdebug.auto_trace

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 追加日志

string xdebug_get_tracefile_name() Returns the name of the function trace file

The possible format specifiers are: Specifier Meaning Example Format Example Filename %c crc32 of the current working directory trace.%c trace.1258863198.xt %p pid trace.%p trace.5174.xt %r random number trace.%r trace.072db0.xt %s script name 2 cachegrind.out.%s cachegrind.out._home_httpd_html_test_xdebug_test_php %t timestamp (seconds) trace.%t trace.1179434742.xt %u timestamp (microseconds) trace.%u trace.1179434749_642382.xt %H $_SERVER[‘HTTP_HOST’] trace.%H trace.kossu.xt %R $_SERVER[‘REQUEST_URI’] trace.%R trace._test_xdebug_test_php_var=1_var2=2.xt %U $_SERVER[‘UNIQUE_ID’] 3 trace.%U trace.TRX4n38AAAEAAB9gBFkAAAAB.xt %S session_id (from $_COOKIE if set) trace.%S trace.c70c1ec2375af58f74b390bbdd2a679d.xt %% literal % trace.%% trace.%%.xt


Search

    Table of Contents