0

我想将 Xdebug 配置设置为它只适用于 CLI 而不是浏览器的位置。原因是我只想为 CLI 测试这个工具。下面是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/

4

1 回答 1

1

如果你不能为 php-cli 和 php-fpm/apache/etc 设置单独的 php.ini 文件,你可以设置xdebug.profiler_enable=0并且分析不会开始。然后设置xdebug.profiler_enable_trigger=1为你有和可选xdebug.profiler_enable_trigger_value = 3236的。

然后在启动 php-cli 命令时添加一个环境变量 XDEBUG_PROFILE=3236。这将开始分析。

XDEBUG_PROFILE=3236 php script.php

请注意,分析也可以通过 Web 请求触发,但执行此操作的人需要知道您的“触发值”。

此处的文档:https ://xdebug.org/docs/profiler

于 2019-11-21T21:54:19.690 回答