【发布时间】: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