Yii 1.1: yiidebugtb

Yii Debug Toolbar

This extension is very useful in the development stage of project. It helps you to get info about PHP environment, application, queries logs, benchmarking with a simple little toolbar at the top of the page.

It is a recreated Symfony's developer toolbar. First idea and very first implementation was my, but this version mostly implemented by Eduard Kuleshov.

This version tested for 1.0.x branch of Yii Framework.

Last update gives additional security option. If you worry about this please download last version. (Check the README file for details)

Working for 1.1.x branch and PHP 5.3 also is good.


NOTE: Project Home Page changed from Google Code to the GitHub.com



  • Yii 1.0 or above


  • Extract the release file under protected/extensions


main.php configuration file update:

  // autoloading model and component classes
    'application.extensions.yiidebugtb.*', //our extension
          'levels'=>'error, warning, trace',
        array( // configuration for the toolbar
          'config'=>'alignLeft, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
          'levels'=>'error, warning, trace, profile, info',

Options are:

  • 'alignLeft' => Debug toolbar will be aligned to the top left corner of browser window
  • 'opaque' => Makes debug toolbar almost invisible when it's minimized
  • 'runInDebug' => Show debug toolbar only if Yii application running in DEBUG MODE (see index.php for details)
  • 'fixedPos' => Makes debug toolbar sticky with browser window, not document!
  • 'collapsed' => Show debug toolbar minimized by default.
  • 'yamlStyle' => Show configuration report in Yaml or PHP-array style.

Also there is an additional security feature you may need - 'allowedIPs' option. This option holds the array of IP addresses of all machines you need to use in development cycle. So if you forget to remove YII_DEBUG from bootstrap file for the production stage, your client don't see the toolbar anyway. By default (if you didn't define it) there is only one IP address in allowedIPs list -

Now you can use regexp patterns in allowedIPs options section to describe which hosts able to view YiiDebugToolbar in a more flexible way. Here is the example which allow to show YiiDebugToolbar to whole bunch of computers in 192.168.10-15.* subnet: '192.168.1[0-5].[0-9]{3}'.

Change Log

January 25, 2011

  • Fixed 'pxt' in styles section of view file
  • Improved allowedIPs option section to use regexp pattern matching (thanks to canni - https://github.com/canni)

September 23, 2010

  • Fixed showing of traceback messages

August 18, 2010

  • Added 'allowedIPs' option to configuration file

March 18, 2010

  • Added 'return' to 'onclick' handlers (http://github.com/cr0t/yiidebugtb/issues/closed#issue/2)

March 15, 2010

  • Fixed fonts, colors and links styles (http://github.com/cr0t/yiidebugtb/issues/closed#issue/1)

February 25, 2010

  • Fixed minor bug with 'Post' and 'Get' arrays of request parameters

January 26, 2010

  • Fixed horizontal scroll, removed borders from yiidebugpanel, also fixed fonts for yiidebugpanel

January 22, 2010

  • Changed project home page from Google Code to Github.com

January 11, 2010

  • Updates and fixes for properly work for 1.1.x branch and PHP 5.3.

January 11, 2010

  • Initial release.

Total 20 comments

#17465 report it
mstdmstd at 2014/06/17 08:01am
show sql with bounded values in 1 sql statement ?

Hi, If there is a way to show sql with bounded values in 1 sql statement ?


#15132 report it
retomi at 2013/10/10 04:13am
great work

I changed these lines to have links more comfortable to use:

. yiiDebugInfoList h2 a {
+     display: block;
protected static function formatArrayAsHtml ($ id, $ values​​, $ highlight = false) {
-       <h2><a href="#" onclick="yiiWebDebugToggleVisible(\'yiiWDCFG' . $id . '\'); return false;">+</a>' . $id . '</h2>'.
+       <h2><a href="#" onclick="yiiWebDebugToggleVisible(\'yiiWDCFG' . $id . '\'); return false;">+' . $id . '</a></h2>'.
#15096 report it
Sergey Kuznetsov at 2013/10/07 06:09am
Pull-requests are welcome

@KonApaz, unfortunately I do not have enough time to work on this extension at the moment. But if you want, you can send a pull-request (via Github - https://github.com/cr0t/yiidebugtb) and I'll merge it into the current source code. You're welcome for pull-requests!

#15095 report it
Kostas Apazidis (KonApaz) at 2013/10/07 06:04am
excellent extension

Good job!

Is there a way to display the time for each trace ?

The time is displayed like that 12:57:03.153287 12:57:04.183274

But I want an extra column to display the consumed time 12:57:04.183274 - 12:57:03.153287 = 1.03...


#10901 report it
le_top at 2012/12/01 01:27pm
Compatibility with CWebServiceAction


This is an excellent extension (I've been using it since some time and it allows for efficient debugging).

I've just added the following piece of code in the processLogs method to disable the extension for CWebServiceAction as the extra data at the end of the webservice reply is not very appreciated by the client:

if(!$allowed) return; // This line already exists.
        if($app->getController()->action instanceof CWebServiceAction) {
#6568 report it
jwerner at 2012/01/19 04:18am
Config Setting to Check for allowed User Names


I needed a config setting to allow the debug toolbar only for some developer users.

Here is my diff:

Index: /home/me/myproject/protected/extensions/debugtoolbar/XWebDebugRouter.php
--- /home/me/myproject/protected/extensions/debugtoolbar/XWebDebugRouter.php    (revision 196)
+++ /home/me/myproject/protected/extensions/debugtoolbar/XWebDebugRouter.php    (working copy)
@@ -446,7 +445,8 @@
 class XWebDebugRouter extends CLogRoute
    public $config = '';
-   public $allowedIPs = array('');
+        public $allowedIPs = array('');
+        public $allowedUserNames = null;
    public function collectLogs($logger, $processLogs = false)
@@ -458,10 +458,50 @@
    public function processLogs($logs)
-       $config = array();
-       if( !in_array($app->request->getUserHostAddress(), $this->allowedIPs) ) return;
+                $config = array();
+                // Check for valid username configured?
+                $allowed = true;
+                if(count($this->allowedUserNames)>0) {
+                    // Deny display first
+                    $allowed = false;
+                    // Check all configured usernames
+                    foreach($this->allowedUserNames as $allowedUserName)
+                    {
+                        if(Yii::app()->user->name==$allowedUserName)
+                        {
+                            $allowed = true;
+                            break;
+                        }
+                    }
+                } else {
+                    $allowed = true;
+                }
+           if(!$allowed) return;
+       $ip = $app->request->getUserHostAddress();
+       $allowed = false;
+       foreach($this->allowedIPs as $pattern)
+       {
+           // if found any char other than [0-9] and dot, treat pattern as a regexp
+           if(preg_match('/[^0-9:\.]/', $pattern))
+           {
+               if(preg_match('/'.$pattern.'/', $ip))
+               {
+                   $allowed = true;
+                   break;
+               }
+           }
+           else if($pattern === $ip)
+           {
+               $allowed = true;
+               break;
+           }
+       }
+       if(!$allowed) return;
        foreach (explode(',', $this->config) as $value)
            $value = trim($value);



#6018 report it
Termine at 2011/12/06 05:25am
Just what I was looking for

Thanks very much for this excellent extension!

#5792 report it
skeef at 2011/11/14 02:35am
Enabled switch

Thanks for a great extension! Seems to me very useful would be a Boolean type switch (enabled => true,false) to turn off the extensions with a single command

#4642 report it
yiiz at 2011/07/28 09:17pm

Great extension! Thx! I used it in all my project.

#4489 report it
Ivica at 2011/07/13 06:24am
Great work

Very handy for debugging Yii projects, thanks for sharing!

#4334 report it
gbasto at 2011/06/27 09:20am
Yii 1.1.8

Someone else had problems with the toolbar after update Yii framework to v1.1.8?

#4242 report it
kokomo at 2011/06/19 01:32pm
Small Bug

Have found a small bug in sessionAsArray(). Described the bug in the extension thread in the forum

Yii Debug Toolbar

#4051 report it
Lupin Sansei at 2011/06/01 11:38am

Of course not, but in development I make it a principle to always have valid output, it helps me find and trace errors.

#3768 report it
nickcv at 2011/05/06 06:52am

oh come on! you are not going to use it in production, so who cares if it validates or not.

#3766 report it
Kamarul at 2011/05/06 04:28am

nice extension. thanks. ^_^

#3761 report it
Lupin Sansei at 2011/05/05 06:09pm
invalid HTML code

The only thing that I do not like about this extension is that it produces invalid (X)HTML code. (It simply appends <style>, <script>, etc. at places where they must not be, uses "(" in an id attribute, uses <center>, etc.) Maybe I can be bothered to fix all this at some point, but until then it screws up my HTML validator which keeps me from using it, as I cannot spot problems as easily then anymore.

#3587 report it
Veseliq at 2011/04/20 02:55pm

Its my most favorite extension. If you like it, here is a potential discussion that might lead to its inclusion in Yii as core feature. Take some time to star it:


#3393 report it
nickcv at 2011/04/08 07:44pm
just love it

you must be a fool to vote against this one.

#3275 report it
nickcv at 2011/03/30 08:01pm
this sounds so good

i'm gonna try this tomorrow morning for sure.

sounds like a great extension

#2997 report it
eirikhm at 2011/03/07 05:17am

Very handy! Keep up the good work!

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: Sergey Kuznetsov
  • Category: Logging
  • Votes: +112 / -5
  • Downloaded: 7,608 times
  • Created on: Jan 11, 2010
  • Last updated: Jan 31, 2011
  • Tags: debug, log