【问题标题】:Visual Studio Code PHP Debug does not stop on breakpoints for Docker projectVisual Studio Code PHP 调试不会在 Docker 项目的断点处停止
【发布时间】:2018-10-16 11:17:26
【问题描述】:

我无法让 VS Code 扩展“Php 调试”在任何断点处停止。我正在我的 Ubuntu 笔记本电脑上从 Docker 运行 php 项目(我想调试)。非常感谢任何建议。

我的设置:

  • Docker 上的 PHP 版本:7.1
  • Docker 上的 XDebug 版本:2.6.1
  • VS Code 中的 PHP 调试版本(在我的笔记本电脑上):1.12.6

我的 VS Code launch.json 文件是:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "log": true,
            "pathMappings": {
                "/var/www/html": "/home/chris/my-test-debugging-project"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

我的 /usr/local/etc/php/conf.d/xdebug.ini 配置是:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=172.17.0.2
xdebug.remote_log=/var/www/html/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_port=9000

XDebug 日志文件(来自在 php.ini 中设置 xdebug.remote_log):

    Log opened at 2018-10-14 05:47:16
    I: Connecting to configured address/port: 172.17.0.2:9000.
    W: Creating socket for '172.17.0.2:9000', poll success, but error: Operation now in progress (29).
    E: Could not connect to client. :-(
    Log closed at 2018-10-

14 05:47:16

PHP Debug 日志输出(来自在 launch.json 中设置 "log": true):

<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true }

【问题讨论】:

  • xdebug.ini 中的行在 xdebug 3 中发生了变化

标签: php docker visual-studio-code xdebug vscode-debugger


【解决方案1】:

尝试设置xdebug.remote_connect_back=1,如果可行,请告诉我。

如果是这样,我们可能应该将此问题作为问题that I previously answered 的副本关闭。

【讨论】:

  • 这已在 xdebug 3 中重命名为 xdebug.discover_client_host
【解决方案2】:

据我所知,9000 是默认使用的 php-fpm 端口。所以如果你对xdebug.remote_port=9000 使用相同的端口,它将无法工作。您可以通过 nginx conf 以我的 cat /etc/nginx/conf.d/site.conf 为例进行检查,您可以检查fastcgi_pass 127.0.0.1:9000; 行或运行lsof -n -iTCP:9000 | grep LISTEN 将显示它是否已使用。我建议你去

  • 将其更改为未使用的值,例如:10000
  • xdebug.remote_host 可能出错,登录到容器并尝试 ping 172.17.0.2 如果它不工作你的 xdebug.remote_host 是错误的。找到宿主机的ip替换为当前的172.17.0.2

【讨论】:

  • 我检查了ip,它是正确的。我更改了端口号,但不幸的是结果相同
【解决方案3】:

我在 VM 上运行本地 linux Web 服务器。并使用 samba 我映射到我的共享的 Windows 设备字母。我遵循了所有建议,但断点没有按预期工作。我只能调试将“stopOnEntry”:true“添加到launch.json,但不能在个人添加的断点上,它们都被忽略了。 我的问题是我的应用程序运行的路径,我这样修复:

{
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9900,             
        "log": true,
       "stopOnEntry": false,
        "pathMappings": {
             "/var/www/html/booking" : "z:",

          }
 },

    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9900
    }
]

}

这个 obiouvsly 是我的 linux 路径 -> "/var/www/html/booking" 这是驱动器映射字母->“z:”

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 2019-03-19
    • 2019-03-31
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多