gpt4 book ai didi

php - 带有 Xdebug 3 env XDEBUG_MODE 的 Docker PHP 不起作用

转载 作者:行者123 更新时间:2023-12-03 13:38:52 26 4
gpt4 key购买 nike

我正在尝试配置 Xdebug 3在 PHP 容器中,并设置 XDEBUG_MODE环境变量为 off根据文档 https://xdebug.org/docs/all_settings#mode但是 xdebug_info()显示 mode=develop .怎么修?
Dockerfile:

FROM php:7.4.11-fpm

ENV XDEBUG_MODE=off
ENV XDEBUG_CONFIG=""
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
...
docker -compose.yml:
services:
php:
build:
dockerfile: ${PWD}/.devcontainer/Dockerfile
image: php-fpm
environment:
XDEBUG_MODE: ${XDEBUG_MODE} // off
XDEBUG_CONFIG: ${XDEBUG_CONFIG}
xdebug 信息:
php -r 'xdebug_info();'
Version => 3.0.0
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled

PHP
Build Configuration
Version => 7.4.11
Debug Build => no
Thread Safety => disabled
Settings
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-amqp.ini,
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
Directive => Local Value => Master Value

xdebug.mode => develop => develop
更新:
我的案例:我使用 VSCode 来调试我的应用程序,所以只有在 Xdebug 监听处于事件状态时才需要打开 Xdebug 模块。更好的方法是使用 env XDEBUG_CONFIG 和 XDEBUG_MODE,因为它不需要更改 ini 文件。

最佳答案

它确实有效。我的意思是:实际行为/最终结果。
尽管它显示 xdebug.mode => develop实际功能全部关闭:

Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled

我已经在 Windows 10 上进行了本地测试 .. 我看到了同样的结果:
php.ini 有
xdebug.mode = debug
没有 XDEBUG_MODE override cmd 显示调试器已按应有的方式启用:
Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✔ enabled
Tracing => ✘ disabled
...
xdebug.mode => debug => debug
XDEBUG_MODE覆盖:
C:\Users\Andriy
$ SET XDEBUG_MODE=off

C:\Users\Andriy
$ php -r "xdebug_info();"

...
Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled
...
xdebug.mode => debug => debug

如果我运行这个命令(传递额外的 Xdebug 配置参数,告诉立即开始调试):
php -dxdebug.start_with_request=yes -r "xdebug_info();"
然后在没有覆盖的情况下,它将尝试建立调试连接,而在没有覆盖的情况下,它不会尝试这样做。这证实了覆盖有效(至少在我的环境中)。

关于php - 带有 Xdebug 3 env XDEBUG_MODE 的 Docker PHP 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65107145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com