I want to set Xdebug configuration as where it should work for just CLI not for browser. The reason is I want to test this tool for CLI only. Below is the xdebug.ini
#this line will be added automatically
zend_extension = /usr/lib64/php/modules/xdebug.so
#add the following
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_enable_trigger_value = 3236
xdebug.profiler_output_name = cachegrind.out.%t
xdebug.profiler_output_dir = /net/tmp/
If you cannot have separate php.ini files for php-cli and php-fpm/apache/etc you can set xdebug.profiler_enable=0
and the profiling will not start. Then set xdebug.profiler_enable_trigger=1
as you have and optionally xdebug.profiler_enable_trigger_value = 3236
.
Then when starting the php-cli command add an environment variable XDEBUG_PROFILE=3236. This will start profiling.
XDEBUG_PROFILE=3236 php script.php
Note that profiling can be triggered also with a web request, but the person doing this would need to know your "trigger value".
Documentation here: https://xdebug.org/docs/profiler