php - VSCode调试器未在Docker上为Laravel运行

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

我正在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"
            }

关于php - VSCode调试器未在Docker上为Laravel运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56379076/

相关文章:

linux - gdb - 目标中不支持硬件断点

php - 如何用PHP和MySQL创建JSON嵌套子父树(PDO方法)

PHP 错误行 1 : `<?php ?>'

mongodb - docker 在不同的端口上运行 mongo 镜像

Dockerfile : not able to run bin command ubuntu

debugging - 为什么是:sprint is showing WHNF even when i evaluate the variable?

php - 更新有关 Woocommerce 中数量变化的购物车项目自定义数据

php - 如果是第一次发帖,风格不同——Wordpress

docker - 如何从最新版本的 Ubuntu (18.10) 运行使用 SystemD 的 Docker 容器?

c++ - 发布构建与调试构建性能