【问题标题】:Vscode debugger not running for laravel on dockerVscode 调试器未在 docker 上为 laravel 运行
【发布时间】:2019-10-16 03:48:15
【问题描述】:

我正在一个 docker 容器中运行一个 laravel 项目,并且我正在使用 vs 代码来调试该项目。 我配置了一个运行良好的 launch.json。 如果我运行docker exec -it main bash,则会显示以下路径映射。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "main",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/home/virta/site/trunk": "/Users/masnadnehith/Desktop/bitbucket/main/"
            },
            "xdebugSettings": {
                "max_data": 65535,
                "show_hidden": 1,
                "max_children": 100,
                "max_depth": 5
            },
            "port": 9000
        }
    ]
}

现在我有一个新项目 laravel 项目,它是一个子模型,我使用 git 克隆并将它添加到“主”目录中,调用它 main core 但我遇到的问题是现在 main core 无法完全运行调试器。 所以现在我像这样创建了第二个配置。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "main",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/home/virta/site/trunk": "/Users/masnadnehith/Desktop/bitbucket/main/"
            },
            "xdebugSettings": {
                "max_data": 65535,
                "show_hidden": 1,
                "max_children": 100,
                "max_depth": 5
            },
            "port": 9000
        },
        {
            "name": "main-core",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/var/www": "/Users/masnadnehith/Desktop/bitbucket/main/main-core"
            },
            "xdebugSettings": {
                "max_data": 65535,
                "show_hidden": 1,
                "max_children": 100,
                "max_depth": 5
            },
            "port": 9000
        },

    ]
}

docker exec 命令用于获取新容器的路径映射。

因此我不确定为什么第一个配置可以完美地调试 laravel 项目,而第二个配置却不是。 第二个使用不同的 docker 容器(顺便说一句)。 第一个在没有安装任何扩展的情况下工作。

PHP 信息已经显示调试器已安装。

xdebug 文件如下

[xdebug]
xdebug.remote_enable=on
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_host=host.docker.internal
xdebug.remote_handler=dbgp
; xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_autostart = on
xdebug.idekey='VSCODE'
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.var_display_max_depth = -1

【问题讨论】:

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


    【解决方案1】:

    与其直接用路径映射端口,不如使用workspaceroot\main-core

    "pathMappings": {
                    "/var/www/": "${workspaceRoot}/main-core"
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 2021-11-27
      • 2021-12-28
      • 1970-01-01
      • 2020-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多