kv4nt / yii2-debug
Yii框架的调试扩展
1.0.5
2022-11-10 07:41 UTC
Requires
- php: >=5.4
- ext-mbstring: *
- rcnowak/yii2: 1.0
Requires (Dev)
- cweagans/composer-patches: ^1.7
- kv4nt/yii2-swiftmailer: *
- phpunit/phpunit: 4.8.34
- yiisoft/yii2-coding-standards: ~2.0
README
Yii 2调试扩展
此扩展为Yii框架2.0应用程序提供调试器。当使用此扩展时,每个页面的底部都会出现一个调试工具栏。该扩展还提供一组独立的页面来显示更详细的调试信息。
有关许可证信息,请检查LICENSE文件。
文档位于docs/guide/README.md。
安装
安装此扩展的首选方法是使用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'], ], // ... ], ... ];
您需要对操作系统进行一些更改。请参阅以下示例
- 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]); },