我正在docker容器中运行laravel项目,并且正在使用vs代码调试项目。
我有一个配置完美的launch.json。
如果我运行docker exec -it main bash,则会显示以下pathMappings。

{
    "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命令用于获取新容器的pathMapping。

因此,我不确定为什么第一种配置能完美地调试laravel项目,而第二种配置却不能。
第二个使用另一个docker容器(btw)。
第一个没有安装任何扩展程序就可以工作。

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

最佳答案

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

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

09-04 01:56
查看更多