Has anyone successfully configured VSCode to debug Laravel-based website? After having followed numerous articles and tutorials, I have made it to the point where I can ask VSCode to "Listen to XDEBUG", but I haven't been able to do normal VS-style debugging where I could just hit F5 to launch current the website in my favorite browser and it would break into VSCode when it hit a breakpoint, just like we do in full Visual Studio or Eclipse.
我在我的机器上正确设置了以下内容:
- VSCode 1.25.1
- XAMPP 1.8
- XDEBUG (configured and working)
- PHP Debug extension for VSCode
我不确定我需要在我的launch.json
中使用什么启动配置.PHP调试扩展附带的两种配置如下所示:
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
虽然第一个配置工作正常(我可以在VSCode中以该模式开始调试,然后在浏览器中单独启动我的网站,它会遇到断点),但第二个配置失败.它告诉我它无法定位Controller
类(这是一个Laravel框架类).用名称空间限定类名也没有任何好处.
My guess is that this has got something to with how the launch configuration is setup. It tries to launch the active script as an independent unit and thus fails to locate the definition of framework classes located in different files. We have to somehow provide launch the website as a single application.
有没有人成功地做到了这一点,并告诉我我错过了什么?