https://xdebug.org/docs/all_settings#trace_format
安装过程略,我是使用的是Mac版本的MAMP Pro,配置文件位于:
/Library/Application Support/appsolute/MAMP PRO/conf/php8.0.8.ini
- 开启develop模式。
如果要记录function trace, 需要开启develop模式。
[xdebug]zend_extension="/Applications/MAMP/bin/php/php8.0.8/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so"xdebug.mode=develop,tracexdebug.start_with_request=yesxdebug.client_host=localhostxdebug.trace_format=0 # 设置记录模式,0是人类阅读友好模式# 设置记录位置xdebug.output_dir="/Applications/MAMP/tmp"
运行后,可以在/tmp中看到trace文件:
TRACE START [2022-06-21 06:04:04.826093]0.0046 401656 -> {main}() /Users/he/www/works/xdebug/index.php:00.0054 401656 -> xdebug_get_tracefile_name() /Users/he/www/works/xdebug/index.php:30.0058 401736 -> var_dump($value = '/Applications/MAMP/tmp/trace.1201524336.xt') /Users/he/www/works/xdebug/index.php:30.0079 329056TRACE END [2022-06-21 06:04:04.829654]
如代码:
<?phpfunction moo() {echo "666";}function foo() {// 尴尬的空格moo();}// 有一个尴尬的空格foo();?>
TRACE START [2022-06-21 06:15:42.596728]0.0032 402136 -> {main}() /Users/he/www/works/xdebug/1.php:00.0039 402136 -> foo() /Users/he/www/works/xdebug/1.php:100.0039 402136 -> moo() /Users/he/www/works/xdebug/1.php:70.0053 329544TRACE END [2022-06-21 06:15:42.599074]
