algsupport / yii2-debug
Yii框架的调试扩展
v0.0.2
2023-12-15 11:34 UTC
Requires
- php: >=8.2
- ext-mbstring: *
- algsupport/yii2: *
This package is auto-updated.
Last update: 2024-09-15 13:53:30 UTC
README
Yii 2调试扩展
此扩展为Yii框架2.0应用程序提供调试器。当使用此扩展时,调试工具栏将出现在每个页面的底部。该扩展还提供一组独立的页面,以显示更详细的调试信息。
有关许可证信息,请参阅LICENSE文件。
文档位于docs/guide/README.md。
安装
安装此扩展的首选方法是使用composer。
运行以下命令之一:
php composer.phar require --prefer-dist yiisoft/yii2-debug
或将以下内容添加到您的composer.json
文件的require部分:
"yiisoft/yii2-debug": "~2.1.0"
使用方法
扩展安装后,只需按照以下方式修改您的应用程序配置:
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'], ], // ... ], ... ];
您必须对您的操作系统进行一些更改。请参阅以下示例
- PHPStorm: https://github.com/aik099/PhpStormProtocol
- Windows或Linux上的Sublime Text 3: https://packagecontrol.io/packages/subl%20protocol
- Mac上的Sublime Text 3: https://github.com/inopinatus/sublime_url
虚拟化或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]); },