kv4nt/yii2-debug

Yii框架的调试扩展

安装: 259

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 149

类型:yii2-extension

1.0.5 2022-11-10 07:41 UTC

This package is auto-updated.

Last update: 2024-09-10 11:22:37 UTC


README

Yii 2调试扩展


此扩展为Yii框架2.0应用程序提供调试器。当使用此扩展时,每个页面的底部都会出现一个调试工具栏。该扩展还提供一组独立的页面来显示更详细的调试信息。

有关许可证信息,请检查LICENSE文件。

文档位于docs/guide/README.md

Latest Stable Version Total Downloads Build Status

安装

安装此扩展的首选方法是使用composer

运行以下命令之一:

php composer.phar require --prefer-dist yiisoft/yii2-debug

或者

"yiisoft/yii2-debug": "~2.1.0"

将其添加到您的composer.json文件的要求部分。

使用方法

安装扩展后,只需按如下方式修改您的应用程序配置

return [
    'bootstrap' => ['debug'],
    'modules' => [
        'debug' => [
            'class' => 'yii\debug\Module',
            // uncomment and adjust the following to add your IP if you are not connecting from localhost.
            //'allowedIPs' => ['127.0.0.1', '::1'],
        ],
        // ...
    ],
    ...
];

您将在应用程序每个页面的底部看到调试工具栏。您可以点击工具栏以查看更详细的调试信息。

在IDE中打开文件

您可以使用此配置创建链接,以在您喜欢的IDE中打开文件

return [
    'bootstrap' => ['debug'],
    'modules' => [
        'debug' => [
            'class' => 'yii\debug\Module',
            'traceLine' => '<a href="phpstorm://open?url={file}&line={line}">{file}:{line}</a>',
            // uncomment and adjust the following to add your IP if you are not connecting from localhost.
            //'allowedIPs' => ['127.0.0.1', '::1'],
        ],
        // ...
    ],
    ...
];

您需要对操作系统进行一些更改。请参阅以下示例

虚拟化或docker化

如果您的应用程序在虚拟化或docker化环境中运行,通常情况下,应用程序的基本路径在虚拟机或容器内与在您的宿主机上不同。为了在这些情况下使链接正常工作,您可以按如下方式配置tracePathMappings(更改您的应用程序路径)

'tracePathMappings' => [
    '/app' => '/path/to/your/app',
],

或者,您可以创建一个回调用于traceLine以获得更多的控制

'traceLine' => function($options, $panel) {
    $filePath = $options['file'];
    if (StringHelper::startsWith($filePath, Yii::$app->basePath)) {
        $filePath = '/path/to/your/app' . substr($filePath, strlen(Yii::$app->basePath));
    }
    return strtr('<a href="ide://open?url=file://{file}&line={line}">{text}</a>', ['{file}' => $filePath]);
},