php配置xdebug扩展

profile配置

xdebug.profiler_enable

xdebug.profiler_enable默认为0,当xdebug.profiler_enable设置为1的时候,xdebug会对每个请求都进行脚本剖析。

xdebug.profiler_output_dir

设置脚本剖析文件的保存位置,默认是存放在/var/tmp/。

可以通过 php --ri xdebug 来查看xdebug的配置,效果如下

php --ri xdebug                                                                                                                                

xdebug

xdebug support => enabled
Version => 2.3.3
IDE Key => PHPSTORM

Supported protocols => Revision
DBGp - Common DeBuGger Protocol => $Revision: 1.145 $

Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_output_dir => /var/tmp/ => /var/tmp/
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.coverage_enable => On => On
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.collect_assignments => Off => Off
xdebug.default_enable => On => On
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.halt_level => 0 => 0
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => On => On
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_output_dir => /var/tmp/ => /var/tmp/
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.profiler_enable_trigger => On => On
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_append => Off => Off
xdebug.profiler_aggregate => Off => Off
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_mode => req => req
xdebug.remote_port => 9001 => 9001
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_log => no value => no value
xdebug.idekey => PHPSTORM => PHPSTORM
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
xdebug.cli_color => 0 => 0
xdebug.scream => Off => Off

xdebug.profiler_enable_trigger

一般情况,没有必要每个请求都需要进行性能剖析,一是占用系统空间,二是影响脚本执行效率。

这个时候,我们可以将xdebug.profiler_enable设为0,xdebug.profiler_enable_trigger设置1。这个效果是,只有GET/POST 或者COOKIE里带上XDEBUG_PROFILE变量,而且XDEBUG_PROFILE的值匹配才可以。

xdebug.profiler_enable_trigger_value

设置触发xdebug进行性能剖析的值。

设置xdebug启动性能分析

php --ini

找到xdebug.ini文件,编辑xdebug.ini,内容如下:

[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
xdebug.remote_enable =1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
xdebug.idekey="PHPSTORM"
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable_trigger_value=""

安装剖析结果阅读器

brew install qcachegrind graphviz

你可能感兴趣的:(php配置xdebug扩展)