Saturday 26 March 2016

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



Any suggestions?


Answer



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


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...