Debug Extension for Yii 2
This extension provides a debugger for Yii framework 2.0 applications. When this extension is used, a debugger toolbar will appear at the bottom of every page. The extension also provides a set of standalone pages to display more detailed debug information.
For license information check the LICENSE-file.
Documentation is at docs/guide/README.md.
Installation ¶
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiisoft/yii2-debug
or add
"yiisoft/yii2-debug": "~2.0.0"
to the require section of your composer.json
file.
Usage ¶
Once the extension is installed, simply modify your application configuration as follows:
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'],
],
// ...
],
...
];
You will see a debugger toolbar showing at the bottom of every page of your application. You can click on the toolbar to see more detailed debug information.
Open Files in IDE ¶
You can create a link to open files in your favorite IDE with this configuration:
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'],
],
// ...
],
...
];
You must make some changes to your OS. See these examples:
- PHPStorm: https://github.com/aik099/PhpStormProtocol
- Sublime Text 3 on Windows or Linux: https://packagecontrol.io/packages/subl protocol
- Sublime Text 3 on Mac: https://github.com/inopinatus/sublime_url
Virtualized or dockerized ¶
If your application is run under a virtualized or dockerized environment, it is often the case that the application's base path is different inside of the virtual machine or container than on your host machine. For the links work in those situations, you can configure traceLine
like this (change the path to your app):
'traceLine' => function($options, $panel) {
$filePath = str_replace(Yii::$app->basePath, '~/path/to/your/app', $options['file']);
return strtr('<a href="ide://open?url=file://{file}&line={line}">{text}</a>', ['{file}' => $filePath]);
},
You can add all posible path like this (valid for advanced template backend main-local.php config):
'traceLine' => function($options, $panel) {
$filePath = $options['file'];
$filePath = str_replace(Yii::$app->basePath, 'file://~/path/to/your/backend', $filePath);
$filePath = str_replace(dirname(Yii::$app->basePath) . '/common' , 'file://~/path/to/your/common', $filePath);
$filePath = str_replace(Yii::$app->vendorPath, 'file://~/path/to/your/vendor', $filePath);
return strtr('<a href="phpstorm://open?url={file}&line={line}">{file}:{line}</a>', ['{file}' => $filePath]);
},
Class Reference
Class | Description |
---|---|
yii\debug\DbAsset | DB asset bundle |
yii\debug\DebugAsset | Debugger asset bundle |
yii\debug\FlattenException | FlattenException wraps a PHP Exception to be able to serialize it. |
yii\debug\LogTarget | The debug LogTarget is used to store logs for later use in the debugger tool |
yii\debug\Module | The Yii Debug Module provides the debug toolbar and debugger |
yii\debug\Panel | Panel is a base class for debugger panel classes. It defines how data should be collected, what should be displayed at debug toolbar and on debugger details view. |
yii\debug\TimelineAsset | Timeline asset bundle |
yii\debug\UserswitchAsset | User switch asset bundle |
yii\debug\actions\db\ExplainAction | ExplainAction provides EXPLAIN information for SQL queries |
yii\debug\components\search\Filter | Provides array filtering capabilities. |
yii\debug\components\search\matchers\Base | Base class for matchers that are used in a filter. |
yii\debug\components\search\matchers\GreaterThan | Checks if the given value is greater than the base one. |
yii\debug\components\search\matchers\GreaterThanOrEqual | Checks if the given value is greater than or equal the base one. |
yii\debug\components\search\matchers\LowerThan | Checks if the given value is lower than the base one. |
yii\debug\components\search\matchers\MatcherInterface | MatcherInterface should be implemented by all matchers that are used in a filter. |
yii\debug\components\search\matchers\SameAs | Checks if the given value is exactly or partially same as the base one. |
yii\debug\controllers\DefaultController | Debugger controller provides browsing over available debug logs. |
yii\debug\controllers\UserController | User controller |
yii\debug\models\Router | Router model |
yii\debug\models\UserSwitch | UserSwitch is a model used to temporary logging in another user |
yii\debug\models\search\Base | Base search model |
yii\debug\models\search\Db | Search model for current request database queries. |
yii\debug\models\search\Debug | Search model for requests manifest data. |
yii\debug\models\search\Event | Event |
yii\debug\models\search\Log | Search model for current request log. |
yii\debug\models\search\Mail | Mail represents the model behind the search form about current send emails. |
yii\debug\models\search\Profile | Search model for current request profiling log. |
yii\debug\models\search\User | Search model for implementation of IdentityInterface |
yii\debug\models\search\UserSearchInterface | UserSearchInterface is the interface that should be implemented by a class providing identity information and search method. |
yii\debug\models\timeline\DataProvider | DataProvider implements a data provider based on a data array. |
yii\debug\models\timeline\Search | Search model for timeline data. |
yii\debug\models\timeline\Svg | Svg is used to draw a graph using SVG |
yii\debug\panels\AssetPanel | Debugger panel that collects and displays asset bundles data. |
yii\debug\panels\ConfigPanel | Debugger panel that collects and displays application configuration and environment. |
yii\debug\panels\DbPanel | Debugger panel that collects and displays database queries performed. |
yii\debug\panels\DumpPanel | Dump panel that collects and displays debug messages (Logger::LEVEL_TRACE). |
yii\debug\panels\EventPanel | Debugger panel that collects and displays information about triggered events. |
yii\debug\panels\LogPanel | Debugger panel that collects and displays logs. |
yii\debug\panels\MailPanel | Debugger panel that collects and displays the generated emails. |
yii\debug\panels\ProfilingPanel | Debugger panel that collects and displays performance profiling info. |
yii\debug\panels\RequestPanel | Debugger panel that collects and displays request data. |
yii\debug\panels\RouterPanel | RouterPanel provides a panel which displays information about routing process. |
yii\debug\panels\TimelinePanel | Debugger panel that collects and displays timeline data. |
yii\debug\panels\UserPanel | Debugger panel that collects and displays user data. |