【问题标题】:How should I make Xdebug run for only CLI php not for UI我应该如何让 Xdebug 只运行 CLI php 而不是 UI
【发布时间】:2019-11-06 11:37:07
【问题描述】:

我想将 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/

【问题讨论】:

  • 你的 cli 和 webapp 有单独的 php.ini 吗?
  • 不,我没有
  • 你试过xdebug.remote_autostart=1
  • 取决于您的设置,可能会或可能不会导致 xdebug 始终在浏览器中运行,因此您必须对其进行测试
  • 是的,这不能满足我的问题。我想要的是我不希望 xdebug 对我的网页进行分析,而是对我的 Cron 和 cli php 文件进行分析

标签: php xdebug xdebug-profiler


【解决方案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

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

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

【讨论】:

    猜你喜欢
    • 2012-08-19
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    相关资源
    最近更新 更多