如何为命令行 PHP 脚本触发 XDebug 分析器? [英] How to trigger XDebug profiler for a command line PHP script?

查看:35
本文介绍了如何为命令行 PHP 脚本触发 XDebug 分析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XDebug 提供配置指令 xdebug.profiler_enable_trigger 允许通过传递 GET 或 POST 参数XDEBUG_PROFILE"来激活分析.通过 HTTP 调用脚本时.如果您不想分析所有脚本,而只想分析少数特殊情况而不总是更改 PHP 配置,这会很方便.

XDebug offers the configuration directive xdebug.profiler_enable_trigger that allows to activate profiling by passing the GET or POST parameter "XDEBUG_PROFILE" when calling a script via HTTP. This is handy if you don't want profiling for ALL of your scripts but only for a few special cases without always changing your PHP configuration.

有没有办法为命令行 PHP 程序实现相同的行为?我试图将 XDEBUG_PROFILE 作为命令行参数传递,但没有奏效.

Is there a way to achieve the same behavior for command line PHP programs? I tried to pass the XDEBUG_PROFILE as a command line argument but it didn't work.

总的来说,分析命令行 PHP 效果很好,但我希望具有与浏览器和 HTTP 服务器相同的每次调用灵活性.

In general, profiling command line PHP works well, but I'd like to have the same per-call-flexibility as with a browser and HTTP server.

推荐答案

您可以使用 -d 标志传递 INI 设置:php -d xdebug.profiler_enable=On script.php.

You can pass INI settings with the -d flag: php -d xdebug.profiler_enable=On script.php.

这篇关于如何为命令行 PHP 脚本触发 XDebug 分析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆