【问题标题】:Xdebug is not working with Visual studio code when using Laradock on Windows 10在 Windows 10 上使用 Laradock 时,Xdebug 无法使用 Visual Studio 代码
【发布时间】:2021-06-11 16:02:42
【问题描述】:

我尝试在 Windows 10 机器上使用带有可视代码的 Laradock 配置 Xdebug。

我看到在使用phpinfo(); 时启用了 Xdebug 我得到了这些值:

Xdebug Version      2.9.8
xdebug.remote_host  host.docker.internal
xdebug.remote_port  9000

我也在调试的Visual Code中启用了这个配置:

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "log": true,
            "stopOnEntry":true,
            "pathMappings": {
                "/var/www": "${workspaceRoot}/public",
            },
            "ignore": [
                "**/vendor/**/*.php"
            ]
        }
    ]

我已经使用以下命令测试了启动 telnet:telnet 192.168.1.10 9000 以查看我可以连接到调试会话。

当我启动浏览器时,我错过了什么让 php-fpm 连接回我的可视化代码会话?我需要发送密钥还是应该只是启动浏览器?

有什么建议可以让我做更多的调试来找出请求被卡住的地方吗?有 xdebug 的日志吗?

【问题讨论】:

    标签: windows visual-studio-code xdebug laradock


    【解决方案1】:

    像这样更新 laradock\php-fpm\xdebug.ini 和 laradock\workspace\xdebug.ini 后,我得到了它的工作:

    xdebug.remote_host=host.docker.internal
    xdebug.remote_connect_back=0
    xdebug.remote_port=9000
    xdebug.idekey=VSCODE
    
    xdebug.remote_autostart=0
    xdebug.remote_enable=0
    xdebug.cli_color=0
    xdebug.profiler_enable=0
    xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
    
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.var_display_max_children=-1
    xdebug.var_display_max_data=-1
    xdebug.var_display_max_depth=-1
    

    我还像这样修改了 .vscode\launch.json:

    {
        // 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",
                //"type": "pwa-chrome",
                //"url": "http://127.0.0.1//posts/first",
                "port": 9000,
                "log": true,
                "stopOnEntry":false,
                "pathMappings": {
                    "/var/www": "I:\\dev\\project-z",
                },
                "ignore": [
                    "**/vendor/**/*.php"
                ]
            }
        ]
    }
    

    自从我在"stopOnEntry":true" 上使用它后,我发现pathMappings 的设置不正确。它在抱怨找不到index.php(这个故障发生在之后,第一个故障)。我认为最初的错误是 "xdebug.remote_connect_back=0" 设置为一个 1

    我还尝试激活以自动启动 chrome(就像它在 phpstorm 中一样),它会启动 chrome 但由于某种原因它不会触发调试(不知道为什么)。我会对此进行更多调查。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-18
      • 2022-10-31
      • 1970-01-01
      • 2017-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-03
      相关资源
      最近更新 更多