PHP:在运行时更改 xdebug.profiler_output_name 选项

Posted

技术标签:

【中文标题】PHP:在运行时更改 xdebug.profiler_output_name 选项【英文标题】:PHP: change xdebug.profiler_output_name option in runtime 【发布时间】:2012-05-08 20:57:14 【问题描述】:

我可以在运行时更改选项 xdebug.profiler_output_name 以指定应用程序模块分析吗?

【问题讨论】:

【参考方案1】:

您无法在脚本中更改探查器输出名称,因为探查器在 php 启动脚本之前启动。因此,当脚本启动时,文件已经创建。不过你应该可以使用.htaccess

Xdebug 的下一个版本 (2.3) 将允许从脚本启动探查器,这也将允许您更改脚本中的xdebug.profiler_output_name 设置(只要您这样做当然是在启动分析器之前)。

【讨论】:

【参考方案2】:

var_dump-ing 时,我使用以下 sn-p 打印出整个对象和字符串:

// make xdebug stop bugging me
ini_set('xdebug.var_display_max_children', 1024);
ini_set('xdebug.var_display_max_data', 1048576);
ini_set('xdebug.var_display_max_depth', 32);

只需将密钥替换为您的 xdebug.profiler_output_name 和所需的值。

【讨论】:

不幸的是,这不起作用。我尝试使用 ini_set('xdebug.profiler_output_name', 'some_name')。当我尝试 echo ini_get('xdebug.profiler_output_name') - 它是“cachegrind.out.%p”

以上是关于PHP:在运行时更改 xdebug.profiler_output_name 选项的主要内容,如果未能解决你的问题,请参考以下文章

在更改时运行PHPUnit测试

动态更改PHP变量(在执行时)

通过 PHP 运行 bash 命令,更改目录然后执行二进制

使用 php sdk 动态更改 Paypal Express 端点

在运行时通过 chmod 更改权限,出现“不允许操作”错误

如何更改全局 PATH php?