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

ttcibm8c  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(145)

我已经安装了Xdebug。我正在调试一个Yii应用程序(版本:1.1.24).但是如果我在方法上设置断点,什么也不会发生。
但如果我做一个非常简单的例子脚本文件在另一个文件夹(只是应用程序与单一文件).就像这样:

<?php

echo 'Hello';
?>

我选择:在控制台中调试当前脚本。然后它将命中代码行。
但在Yii应用程序中,它没有遇到任何断点。
因此,对于Yii应用程序,launch.json看起来像这样:

{
    // 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应用程序?

5gfr0r5j

5gfr0r5j1#

您必须在配置部分“启动内置Web服务器”中将“cwd”的值从“${workspaceRoot}”更改为“/your_app_path/web/”,这对我来说很好:)

相关问题