博客列表 >Docker for windows环境设置VsCode PHP断点调试

Docker for windows环境设置VsCode PHP断点调试

书声的博客
书声的博客原创
2020年09月21日 11:46:581506浏览

Docker for windows环境设置VsCode PHP断点调试

确保docker容器中已安装对应的Xdebug插件

一、VsCode配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "hostname": "192.168.20.51",
            "stopOnEntry": true,
            "pathMappings": {
                // "/data/htdocs/decoration": "${workspaceRoot}"
                //"/data/htdocs/common": "E:\\data\\htdocs\\common"
         
                // "/data/htdocs/容器中的项目目录名": "E:\\data\\htdocs\\本地项目目录名"
              
                "/data/htdocs/容器中的项目目录名": "E:\\data\\htdocs\\本地项目目录名"
                
                //"/data/htdocs/容器中的项目目录名": "E:\\data\\htdocs\\本地项目目录名"
                
            },
            "log": true,
            "port": 9002,
            "externalConsole": false,
            "ignore": [
                "**/vendor/**/*.php"
            ]
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "hostname": "192.168.20.51",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9002
        }
    ]
}

---

"version": "0.2.0",
    "configurations": [
        
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "hostname": "192.168.2.1",//docker宿主机IP,cmd窗口使用ipconfig查看
            "stopOnEntry": true,
            "pathMappings": {
                //"/data/htdocs/css": "${workspaceRoot}"
                "/data/htdocs/css": "E:\\data\\htdocs\\css" 
                //data/htdocs/css docker容器中项目地址
                //E:\\data\\htdocs\\css本地开发项目的绝对路径
            },
            "log": true,
            "port": 9002,//docker镜像配置中开启对应端口
            "externalConsole": false,
            "ignore": [
                "**/vendor/**/*.php"
            ]
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "hostname": "192.168.2.1",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9002
        }
    ]

docker配置:

1.png

2.png


到这一步就差不多了,如果还有问题,请百度一下

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议