zim32 / xhprof-profiler-bundle
此包向 symfony 调试工具栏中添加额外的 XHProf 菜单项
v1.1.0
2020-06-06 09:42 UTC
Requires
- php: ^7.0
- symfony/framework-bundle: ^4.0|^5.0
Suggests
- ext-tideways_xhprof: This package requires tideways_xhprof extension. Activate it for FPM only
This package is auto-updated.
Last update: 2024-09-06 19:18:17 UTC
README
安装
安装 tideways_xhprof 扩展
查看 https://github.com/tideways/php-xhprof-extension 以获取说明
安装此包
composer require zim32/xhprof-profiler-bundle
打开您的 .env.local 文件并添加以下内容
ZIM_XHPROF_ENABLE=1
这将激活分析器。
将 ZIM_XHPROF_ENABLE 设置为 0,或完全删除,以禁用分析器
导航到调试工具栏并单击 XHProf 菜单项。盈利
条件分析
如果您需要根据某些条件启用分析,您可以使用特殊变量 ZIM_XHPROF_CONDITION
此变量的值传递给 Symfony ExpressionLanguage 组件,其中有一个名为 ctx 的变量。此表达式必须评估为布尔值(true - 启用分析,false - 禁用)
CTX 的初始化如下
$ctx->get = $_GET;
$ctx->post = $_POST;
$ctx->server = $_SERVER;
$ctx->cookie = $_COOKIE;
例如,要只为您的用户会话启用分析器,您可以使用
ZIM_XHPROF_CONDITION='key_exists("PHPSESSID", ctx.cookie) && ctx.cookie["PHPSESSID"] === "bd465k5q41n8jsdd8iu99mmchk"'