在 Windows 11 上附加到 docker 托管的 PHP / Xdebug 不工作

问题描述 投票:0回答:0

多年来我一直在使用 VS-Code 和 XDebug3,并在基于 Wampserver 的设置上取得了成功,但我需要转移到 docker 环境。我已经设置了一个可用的 MariaDB/Apache/PHP docker 服务器,但无法进行调试。

这是php.ini文件中的设置

zend_extension=xdebug.so
xdebug.mode=debug
# the default port for XDebug 3 is 9003, not 9000
xdebug.client_port=9003
# The line below is commented. This is the IP of your host machine, where your IDE is installed.
# We set this IP via XDEBUG_CONFIG environment variable in docker-compose.yml instead.

docker-compose.yaml
我配置了XDEBUG_CONFIG来监听host.docker.inernal:

      XDEBUG_CONFIG: client_host=host.docker.internal # This is for XDebug 3. For XDebug 2, we should use remote_host instead of client_host.
    extra_hosts:
         - "host.docker.internal:host-gateway"

这似乎被 PHP 拾取为

phpinfo();
报告

xdebug.client_host  host.docker.internal    localhost
xdebug.client_port  9003    9003

是的,在 VSCode 中,我已将 XDebug 设置为收听 9003。

lauch.json

  "configurations": [
    {
      "name": "Listen for Xdebug",
      "type": "php",
      "request": "launch",
      "port": 9003
    }

当我使用 wampserver 设置时,我已经使用

Xdebug helper
启用了调试,但是当我在 VSCode 中设置断点时,这并没有命中。

我还需要什么来连接到在 Docker 容器中运行的 PHP XDebug 会话?

docker vscode-extensions xdebug
© www.soinside.com 2019 - 2024. All rights reserved.