Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger XDebug profiler for a command line PHP script?

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.

like image 272
selfawaresoup Avatar asked Feb 18 '10 12:02

selfawaresoup


People also ask

How do I trigger xdebug Profiler?

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 .

How does PHP xdebug work?

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).


1 Answers

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

like image 135
jou Avatar answered Sep 23 '22 11:09

jou