gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:25:43 30 4
gpt4 key购买 nike

我正在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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com