如何在Visual Studio代码中调试YII应用程序?

发布于 2025-01-24 07:14:33 字数 1891 浏览 3 评论 0原文

我已经安装了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2025-01-31 07:14:33

您必须将“ c​​wd”的值从'$ {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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文