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.
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.
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.
You can also selectively enable the profiler by setting xdebug. start_with_request#trigger to trigger . You can then enable the profiler by using an environment value, a GET/POST parameter, or COOKIE variable of the name XDEBUG_TRIGGER .
When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).
You can pass INI settings with the -d
flag: php -d xdebug.profiler_enable=On script.php
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With