首页 > 解决方案 > 在 Ubuntu 中使用 VSCode 和 PHP (7) 调试器

问题描述

我在 Ubuntu 中使用 VSCode 来处理一个 php 项目。我使用 php 调试器扩展(和 xdebug)工作得很好,但现在它突然停止工作。(没有更新,没有改变配置。只是一个简单的重启计算机)。确切的问题是 VSCode 不会在代码中的断点处停止。

Netbeans 与 xdebug 配合得很好,所以我不知道什么会导致 VSCode 出现这个问题。

我应该尝试任何提示或想法?

提前致谢。

我已经更改了运行 xdebug 的端口,从 Internet 尝试不同的 launch.json,但不知道发生了什么。我最近激活了日志选项,并且我有一些来自 vscode 的输出,关于“格式错误的 HTTP 请求”,我想这是一个线索。

这是我设置的配置的launch.json 文件。(xdebug 位于 php.ini 文件中的 9090 端口)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [        
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9090,
            "log": true
        },
        {
            "name": "Launch server",
            "type": "php",
            "request": "launch",
            "program": "${workspaceRoot}/site/index.php",
            "runtimeExecutable": "php",
            "runtimeArgs": [
                "-dzend_extension=/usr/lib/php/20170718/xdebug.so",
                "-S",
                "0.0.0.0:9090"
            ],
            "cwd": "${workspaceRoot}",
            "port": 9090,
            "log" : true
        }
    ]
  }

VSCode 日志的输出:

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

<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body:
   { category: 'stderr',
     output:
      '[Fri Nov  1 10:50:06 2019] 127.0.0.1:49922 Invalid request (Malformed HTTP request)\n' } }

标签: phpvisual-studio-codevscode-debugger

解决方案


这很尴尬,但我用 CTROL + F5 执行 iDE,而不仅仅是 F5(我习惯于 Visual Studio)。

这就是整个问题...

谢谢!


推荐阅读