如何在Visual Studio代码中调试YII应用程序?
我已经安装了Xdebug。我正在尝试调试YII应用程序(版本:1.1.24)。但是,如果我对该方法提出了断点,则什么都不会发生。
但是,如果我在另一个文件夹中制作一个非常简单的示例脚本文件(只需使用单个文件)。就像这样:
<?php
echo 'Hello';
?>
我选择:控制台中的当前脚本。然后,它将击中代码线。
但是在YII应用程序中,它没有达到任何断点。
因此,启动。json在YII应用程序中看起来像这样:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
所以我的问题是。如何在VSCODE中使用Xdebug调试YII应用程序?
I've installed Xdebug. And I'm trying to debug a Yii application (version: 1.1.24). But if I put a breakpoint on the method nothing happens.
But if I make a very simple example script file in another folder (just app with single file). Just like this:
<?php
echo 'Hello';
?>
And I choose: debug current script in console. Then it will hit the code line.
But in the Yii application it doesn't hit any breakpoint.
So the launch.json looks like this for the Yii application:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
So my question is. How to debug a Yii application with Xdebug in VSCode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将“ cwd”的值从'$ {worksPaceroot}'更改为'/your_app_path/web/'在“配置”部分“启动内置的Web服务器”中,这对我来说很好:)
You must change the value of 'cwd' from '${workspaceRoot}' to '/your_app_path/web/' in the config section "Launch Built-in web server", that's work fine for me :)