📜 ⬆️ ⬇️

Yii-debug-toolbar extension

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:



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
#... 'log'=>array( 'class'=>'CLogRouter', 'enabled'=>YII_DEBUG, 'routes'=>array( #... array( 'class'=>'CFileLogRoute', 'levels'=>'error, warning', ), array( 'class'=>'application.extensions.yii-debug-toolbar.YiiDebugToolbarRoute', 'ipFilters'=>array('127.0.0.1','192.168.1.215'), ), ), ), #... 

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:

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:
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.

Source: https://habr.com/ru/post/127234/


All Articles