Good time of day habravchane.
Today I would like to tell you about a great yii-debug-toolbar extension from Sergey Malyshev.
In short
This extension adds a very nice and convenient debug panel.
')
yii-debug-toolbar has 5 tabs:
- Server: displays information from phpinfo ();
- Time: displays the page load time, memory size, and session size;
- Globals: displays dumps of global variables ($ _SERVER, $ _COOKIE, $ _SESSION, $ _POST, $ _GET, $ _FILES);
- Settings: displays the configuration of the application (all parameters, components and global settings);
- SQL: displays information about the SQL server and the log for SQL queries (the query itself and the execution time);
- Logging: displays log information (sent via Yii :: log).

Installation
So, to install such a panel on your test server, you will need to download the latest version of the source code from here
www.yiiframework.com/extension/yii-debug-toolbar . Unpack the archive in the folder / protected / extensions. Then in the config we write to the log component
After that, a blue beetle (ala firebug) should appear at the top right. If you have it, then you have done everything correctly.
Customization
All parameters of the component inherits from CLogRouter. But it also has one parameter: ipFilters. This is an array of allowed IP addresses. If you do not want to accidentally post a copy of the debug bar to the production, then enter your IP address there, and the panel will be accessible only from your computer.
Parameters inherited from CLogRouter:
- bool enabled: if false, then debug is disabled (I usually put the constant YII_DEBUG there, then you can quickly and globally disable debug);
- string levels: a list of logging levels separated by comma or space;
- string categories: list of logging categories separated by comma or space;
- array filter: additional filters (for example CLogFilter);
- array logs: logs collected during program execution.
For sweet. How to create your dashboard in yii-debug-toolbar?
The author of the extension took care of the developers using his product and made it possible to add his own tabs painlessly. Let's try to create a panel called “Test”. To do this, add a new file YiiDebugToolbarPanelTest.php to the folder / protected / extensions / yii-debug-toolbar / panels and create a new class YiiDebugToolbarPanelTest in it, which is inherited from YiiDebugToolbarPanel. This class must implement 5 methods:
- getMenuTitle: method returns the name of the tab in the sidebar;
- The getMenuSubTitle: method returns a description of the tab in the sidebar;
- getTitle: the method returns the name of the tab directly inside the tab (at the top, on the yellow bar);
- getSubTitle: the method returns the description of the tab directly inside the tab (at the top, on the yellow bar);
- run: displays content taba.
And add a tab to the $ _panels property of the YiiDebugToolbar class (/protected/extensions/yii-debug-toolbar/YiiDebugToolbar.php)
class YiiDebugToolbarPanelTest extends YiiDebugToolbarPanel{ function getMenuTitle(){ return 'Test'; } function getMenuSubTitle(){ return 'subtest'; } function getTitle(){ return 'TEST v1.0'; } function getSubTitle(){ return 'Hello Vasya'; } function run(){ echo '<h4>'.self::getSubTitle().'</h4>'; echo rand(); } }
Result:

If anyone is interested, in the next article I can tell you how to write your logger.
With respect, Roman.