I found an interesting article: Linux 25 PHP Security Best Practices For Sys Admins
Monthly Archives: August 2019
php -d xdebug.profiler_enable=1
So to enable profiling on the command line run your script in PHP like this:
php -d xdebug.profiler_enable=1 /path/to/script.php
You need to have configured xdebug in php.ini, I do it with a file in /etc/php/7.2/cli/conf.d/xdebug.ini
that looks like this:
;xdebug.profiler_enable = 0 xdebug.profiler_output_dir = "/tmp/xdebug" xdebug.profiler_output_name = "cachegrind.out.%p"
Note: you can enable profiling for all scripts with xdebug.profiler_enable = 1