zim32 / xhprof-profiler-bundle
This bundle add additional XHProf menu item in symfony debug toolbar
Installs: 1 583
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Language:HTML
Type:symfony-bundle
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: 2025-04-06 20:30:19 UTC
README
Installation
Install tideways_xhprof extension
See https://github.com/tideways/php-xhprof-extension for instructions
Install this bundle
composer require zim32/xhprof-profiler-bundle
Open your .env.local file and add
ZIM_XHPROF_ENABLE=1
This will activate profiler.
Set ZIM_XHPROF_ENABLE=0, or remove entirely, to deactivate profiler
Navigate to debug toolbar and click on XHProf menu item. Profit
Conditional profiling
If you need to enable profiling based on some condition, you can use special variable ZIM_XHPROF_CONDITION
The value of this variable is passed to Symfony ExpressionLanguage component, with one variable called ctx. This expression must evaluate to bool value (true - enable profiling, false - disable)
CTX is initialized as follows:
$ctx->get = $_GET;
$ctx->post = $_POST;
$ctx->server = $_SERVER;
$ctx->cookie = $_COOKIE;
So for example to enable profiler only for your user session, you can use
ZIM_XHPROF_CONDITION='key_exists("PHPSESSID", ctx.cookie) && ctx.cookie["PHPSESSID"] === "bd465k5q41n8jsdd8iu99mmchk"'