Giter Club home page Giter Club logo

yii-debug-toolbar's Introduction

Yii Debug Toolbar

The Yii Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.

It is a ported to PHP famous Django Debug Toolbar.

Currently, the following panels have been written and are working:

  • Server info
  • Request timer
  • A list of superglobals
  • Application settings
  • SQL queries including time to execute and param bindings
  • Logging output via Yii built-in logging

Installation

Extract the yii-debug-toolbar from archive under protected/extensions

Usage and Configuration

For use yii-debug-toolbar need to specify new route in log component:

<?php
//...
    'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
            array(
                'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
                // Access is restricted by default to the localhost
                //'ipFilters'=>array('127.0.0.1','192.168.1.*', 88.23.23.0/24),
            ),
        ),
    ),
  • Make sure your IP is listed in the ipFilters setting. If you are working locally this option not required.
  • Enable Profiling and ParamLogging for all used DB connections.
<?php
//...
	'db'=>array(
	    'connectionString' => 'mysql:host=localhost;dbname=test',
	    //...
	    'enableProfiling'=>true,
	    'enableParamLogging'=>true,
	),

TODOs and BUGS

See: issues

Working preview

Screenshot1

Screenshot2

Screenshot3

yii-debug-toolbar's People

Contributors

akimsko avatar bazilio91 avatar bwoester avatar gregmolnar avatar gureedo avatar igorgolovanov avatar igorsantos07 avatar k4emic avatar malyshev avatar naki avatar pavel-main avatar psrustik avatar resurtm avatar rmrevin avatar ryadnov avatar sbesedkov avatar schmunk42 avatar xbazilio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii-debug-toolbar's Issues

ajax

Hi :)

I perform some ajax get and post calls. Get actions usually end with $this->renderPartial, while Post actions usually end with Yii::app()->end()

Anyway I do not see any sql query log in debug bar. Am I missing something? :) thx 👍

Bug with db component

If you take a stock Yiic generated yii app, include your extension, and delete your 'db' in the main config.php you'll cause a null in your extension. It was messing up my theme in the rest environment

Error

Hello, install this extension, but get error:

PHP Error
Trying to get property of non-object
yii-debug-toolbar/yii-debug-toolbar/views/yii_debug_toolbar.php(9)

Errors with APC opcode cache enabled

Hi. I think this project is amazing. I did, however, encounter a bug that I spent a rather long time trying to troubleshoot:

With APC enabled, the yii-debug-toolbar gets its opcode cached which causes errors in any execution after the first. Since Yii has its unique autoloading mechanism we can't selectively set the debug toolbar's directory (via .htaccess):

php_flag apc.cache_by_default 0

If the entire Yii project has its opcode cache disabled the debug toolbar works as-expected. Either a fix or at least a mention in the documentation would be helpful so others don't spend time debugging the debugger. ;-)

Explicit Yii required version

Using the current debug toolbar on a Yii 1.1.6 application crashes. The toolbar's code refers to CController::actionParams which was added on Yii 1.1.7.
It would be nice if the changelog mentionned this requirement. Adding a test in the code would also be nice.

After collecting logs other event handlers cannot save states

it happens if there is more event handlers attached to onEndRequest. All of them can't save states to session after Yii-debug-bar. Bug is not permanent, but sometimes we had problems with flash messages, user states & other things that tried to save their data via states to session.

Yii::app()->end()

When Yii::app()->end() is sent the toolbar should be disabled as this is usually used when exiting with content and the debug toolbar still sends it's html out.

Sql bound params cut off

You can have html in parameters and in that case the log doesn't show the correct parameter value if contains another "=".

Just replace:

list($key,$value) = explode('=', $param);

with

list($key,$value) = explode('=', $param, 2);

Routes exclusion

Add possibility to exclude some routes (disable tool-bar rendering for specific controllers/actions )

Problem when using modules

I try to use the extension in an application with modules and it doesn't work. The PHP code produced by the extension is returned in the source.
I'm not sure it's because I use modules but with another app without modules, I worked perfectly.

bug in binding sql params with commas

if in condition use something with commas ( status IN( :status ) , status => '101,102',), then sql params binding don't work properly, because there are exploding by comma on line 364 in file \yii-debug-toolbar\panels\YiiDebugToolbarPanelSql.php
$params = explode(',', $params);
then on line 370 exploding by =
list($key,$value) = explode('=', $param, 2);
and offset 1 is undefined. Then we have html code of PHP Notice appended to sql panel of toolbar, it append stylesheets too, in result - site looks bad.

Такая вот беда =)

CSS close images

I was observing 404 errors in console, so I changed the lines 169 - 175 of the style.css file from:

    background:url(../close.png) no-repeat center center;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA7dJREFUeNqsWM1PE0EU3+7ShdJKoTRA8UYgIUKM3rmaEI0euXsw0YMHIZEbxBijEiIHLkb/A44SDYlXzkYPGBM+ri1NWz7aUmhp6+9tps10mLfdfrzkl2535r39zc77mvUdHh4abUoUCAD3xP/fQAFItWJkYmLC+e1p8eGPgQcC08ycf8BPgW2vhr0SeQa8AWIe5k4LvATiwCrwtZmS2WT8IfAL+OKRhCoxoftH2GqLyBLwHbhvdC53ha2lVrfmE/DKzbLP5yubplnt7e310f+rq6tqpVLxVatVy0VtHbgNLHohsupGIhQKFQG7v79f+8CLiwsjl8sVAZsxQbYTwFrDwpTwpaj4ptPu6+vLDw4OBkHA014QobOzs3yhUAgyUx4BP2rhq/rIe53GwMBAeXx83DMJEpobi8WCpMtMWeOc9TkwoyMRjUattrMedBkyM+KZN4isqDMDgUCuExIyGbKlGVpRiSzo8kQ4HA4ZXRLGVuzo6GhBJjKviw6dT5TLZSOTyRinp6cGQrV+n67hnEY6nTaur6+1PkM2NWTm5fCd0xDRhh89CKHpXCMijLGxMef6+PjYiRSSUqlUv6/arOlKMlcjQlV0qsGDTZPehpYIxurXRCSRSFByq5NQ56hvhWwj8cm2p7A9UdKYVBX8fn+F2+tIJGIgmzaQkUnYtm0MDw+zvsLYniQiEc2q/WxxwmqRHxrISA9xxiyLDzTGdsRsJwJoK3QPo3vctnhpAzLqTexhiVOg6JAdU5bLy0vHZ+Ro8mg7Q0QO1LvwenZZJycnN3yCIPsMRRYnjO0DU/SY+wprW7fiWmjKJMgnUIcafEaeoxZCJWJI9lH4UjV2u6pSPp/XJR9jaGiIKrERDAbrjllzYOQJZ4zm6ISxuSsntB3gqTyazWZtMowa0aBFb4HegC6aRkZG2C2hLSObmqEdOcVvUdJUZyBlZ7tVa1ASdEUvjW3ZUqvvO82e3kqlUuVOSZANvBFd0fugawM2VKclOT8/tzohQ7pkgzn/rHNdvLbLJkPxeDzHRRIXIaTDkCB57XacoJPZW8bZQpSskslk0Y0QjdEcmstsB8myegrsYbqmENfJU3dOpZyOEwjdCqLIWUyxWKygVzHFccJ2eVkbar/qdq5ZFC3/R5dUb6EBsqQmyEtLuawj0eykRwpPgL0uRO+esLXW7tmX9nEWeAEk2yCQFLqzzb4MeK3Zn4FRsapNEXqGy2eJTTF3VOh27bOE/Ia2pQ81YeCO+P+XknGrH2pq8l+AAQDv/n2Gmq99BgAAAABJRU5ErkJggg==);
}

#yii-debug-toolbar .yii-debug-toolbar-panel-title .yii-debug-toolbar-panel-close:hover {
    background-image:url(../close_hover.png);
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABCVJREFUeNqsWG1IU1EYfjfd0i1bTc2WFTW3tG2aFWlEf4KkMIrCvhH6U9Dn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rPKgMvSoCU2vbhEIEpGBKcw6qQ1LLNmrWaVioRIk2kUtvK4SsWSVaCdl8cbcjxW8UxOZqcRJ2TThITZCO+HZvB2dsQsnnUFNtAtWRpLZ430FKjinH0VHSdCXg8EhwaFS03WbEjR6Sc7TkRCoErp2beKlvwX+EtkKqRkGATEYTXSY4SSkx5x2Eyr7WStnXLVJXr2JfPoQBxEDCYgYJD6Oib7MqC0DLiOyKFPVU9TD2J8lqinY3Oo75R9lhC/oQbRhxoSIDZ63UGK9Xg/1ETsnwADAJrrTk7nZiozAAAAAElFTkSuQmCC);
}

to

    background: url(close.png) no-repeat center center;
}

#yii-debug-toolbar .yii-debug-toolbar-panel-title .yii-debug-toolbar-panel-close:hover {
    background-image: url(close_hover.png);
}

I removed the encoded images as all the others are external and corrected the path.

assets/ajax.php is dangerous

This file has many problems.

  1. It contains hard-coded paths that may not work, e.g. if there is no directory named yii-1.1.8.r3324 or if the application is not in the document root of the web server.
  2. It won't work on some well-configured servers, because the PHP engine is disabled in the assets/ directory.
  3. While the access to the toolbar is filtered, this file is in free access to everyone.
  4. When the assets directory allows php files, this "ajax.php" file is dangerous with GET parameters like ?deleteasset=../. It will recursively delete files in the document root of the server.

I believe this makes "assets/ajax.php" a critical bug with a major security concern.

No support for CProfileLogRoute?

CProfileLogRoute shows the benchmarks which you set using Yii::beginProfile() and Yii::endProfile(). Very useful for finding the choke points in the application.

No toolbar is shown if YII_DEBUG is set to false

If the constant YII_DEBUG is set to false, then the debug toolbar is initialized (its JS is loaded) but it is not shown (no HTML).
Tested on a fresh install of Yii 1.1.8 whith the latest code for yii-debug-toolbar.

wrong links when base tag is present

If the site includes a <base> tag the toolbar links always redirect you to the base url when clicked.
For example let's say that you have a <base href="http://test.com/"> in your template and you are visiting an internal page like http://test.com/foo/bar.html, if you click on a link of the toolbar you will be redirected to http://test.com#yw1, this makes impossible to debug internal pages.
This happens because the href of the links is in format "#name", to fix it you can simply include the current page url before the fragment.

Use instanceof instead of is_a

Otherwise on PHP 5.2.x it will cause error with E_STRICT. (Not with 5.3.x anymore, but many of us still have to use 5.2.x.)

Issue with Twig view renderer

I receive error in last version Controller SiteController can't find view "index" when tries to open index page of site with this extension installed. I'm using Twig as views renderer and extension of views files is ".twig".

For console mode do not include JS

If you run in console mode it kills the entire app for several reasons:

exception 'CException' with message 'CConsoleApplication and its behaviors do not have a method or closure named "getClientScript".'

{main}CException: CConsoleApplication and its behaviors do not have a method or closure named "getViewRenderer".

php 5.4 Illegal string offset 'class'

В php 5.4 выдаёт ошибку Illegal string offset 'class'
/extensions/yii-debug-toolbar/YiiDebugToolbar.php(186)
186 isset($config['class']) || $config['class'] = $id;

Clicking the icon doesn't work

Clicking the icon in the top right doesn't do anything. Is there java script missing? this is what the div looks like.

using version malyshev-yii-debug-toolbar-95c08de on yii 1.1.8


Панель не отображается когда в логах ничего нет

Собственно в теме всё и написано. Как проверить:

  1. Создаём пустой webapp в Yii 1.1.13
  2. Подключаем в него yii-debug-toolbar согласно мануалу
  3. В index.php комментируем строку:
defined('YII_DEBUG') or define('YII_DEBUG',false);

Панель пропадёт. Появится если, например, в контроллере сделать Yii::log('something');

Решение найдено, будет запушено ниже :) Это место аналогично как для dev так и для main ветки.

YiiDebugToolbarPanelSql sqlite exception

Sometimes the last panels Sql and ViewsRendering are breaking the stylesheets and some layouts looks different. On the same page the debugbar javascript is not working anymore (panel doesn't open). At first i thought this happens because the views are outside of tag, but it seems that the reason is different.

Actually this behavior is happening because of PHP Warning:

preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (?< at offset 3

/protected/extensions/debug-toolbar/panels/YiiDebugToolbarPanelSql.php(365)
This is the actual line:

$matchResult = preg_match_all("/(?[a-z0-9._-:]+)=(?[\d.e-+]+|''|'.+?(?<!)')/ims", $params, $paramsMatched, PREG_SET_ORDER);
The layout problem is triggered because of inline styles in yii/framework/views/exception.php.

I'm using sqlite database, maybe this is raising the exception.

Error: yiiDebugToolbar is not defined

ReferenceError: yiiDebugToolbar is not defined
   yiiDebugToolbar.init();

It seems like the script is not registered at the time of the call. If you change POS_END to POS_HEADER it works:
YiiDebugToolbar, L#168-9:

$cs->registerScriptFile($this->assetsUrl . '/yii.debug.toolbar.js',
                CClientScript::POS_HEAD);

CClientScript::POS_END

Hello,

first of all, very good work !!!

I needed to add CClientScript::POS_END to the registerScriptFile call on line 153 of "YiiDebugToolbar.php".

E.g.: $cs->registerScriptFile($this->assetsUrl . '/yii.debug.toolbar.js', CClientScript::POS_END);

The reason is that I have this setup:

'clientScript' => array(
'scriptMap' => array(
'jquery.js' => false,
'jquery-ui.js' => false,
'jquery.min.js' => false,
'jquery-ui.min.js' => false,
'jquery.metadata.js' => false,
),
'coreScriptPosition' => CClientScript::POS_END,
)

2nd Database Connection Error

I extended CActiveRecord to setup a second database connection to a data warehouse. I named the database connection "dw". The toolbar doesn't render on pages that use the dw connection. The rest of the page seems to render fine.

The toolbar is in the HTML, and if I force it to be display "block" instead of "none" I can see it. Further, if I force the SQL block to display, I can see info for the "db" connection, but not the "dw" connection.

This is the error in the Apache log:

PHP Fatal error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in /home/brad/projects/dca/protected/extensions/yii-debug-toolbar/YiiDebugToolbar.php on line 145

Server:

Ubuntu 10.04.2 LTS
PHP 5.3.2
Apache 2.2.14.

Missing Сookie method

После установки возникает ошибка:

TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie' [http://localhost/assets/1cbe31e6/yii.debug.toolbar.js:10]

В коде есть

<script type="text/javascript" src="/assets/51f54240/jquery.js"></script>
<script type="text/javascript" src="/assets/51f54240/jquery.cookie.js"></script>

Alias "ext.yii-debug-toolbar.YiiDebugToolbarRoute" is invalid. Make sure it points to an existing PHP file and the file is readable.

I'm now to yii, and was very interested to your toolbar, but have the above error after activating.

The document (if I understand correctly) states to extract the tool into protected/extensions, i.e protected/extensions/yii-debug-toolbar/YiiDebugToolbarRoute.php exists as a path

I put the following in main.php:
'routes'=>array(
array(
'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',

is "extensions" the right place to put it? Why is "ext." above?

thanks in advance

JS bug on log panel

In the log panel, clicking on a line will show the details. But once I have clicked on the global "details" JS action in the table header, then clicking on a line has no effect.

SQL execute

Possibility to execute SQL query from SQL callstack and get results

Property "SiteController.actionParams" is not defined.

Description

Property "SiteController.actionParams" is not defined.

Source File

/var/www/yii/4/tomik/protected/extensions/yii-debug-toolbar/components/YiiDebugViewRenderer.php(77)

00065: 'render',
00066: 'renderPartial'
00067: )) )
00068: {
00069: break;
00070: }
00071: }
00072:
00073: array_push($this->_debugStackTrace, array(
00074: 'context'=>$context,
00075: 'contextProperties'=> get_object_vars($context),
00076: 'action'=> $context instanceof CController ? $context->action : null,
00077: 'actionParams'=> $context instanceof CController ? $context->actionParams : null,
00078: 'route'=> $context instanceof CController ? $context->route : null,
00079: 'sourceFile'=>$sourceFile,
00080: 'data'=>$data,
00081: 'backTrace'=>$backTraceItem,
00082: 'reflection' => new ReflectionObject($context)
00083: ));
00084: }
00085:
00086: }

Debug hotkeys

The hotkeys enables keyboard navigation and shortcuts for enable/disable component and toggling the panels.

ipFilter for wildcard IPv6 addresses not working

I would like to add a wild card for ipv6 addresses like this:

::ffff:192.168.0.*

This is needed because my nginx server returns ip addresses in that format.

The rule

// IPv6
            else if ($ip === $filter)
            {
                return true;
            }

does not allow wildcards

yiiDebugToolbar not defined (javascript)

Hello,

I downloaded the Debug Toolbar today (7/5/12) from github, and followed the installation instructions.

I'm getting the following javascript error:

Uncaught ReferenceError: yiiDebugToolbar is not defined

on this line:

(function($) {$(function(){yiiDebugToolbar.init()})}(jQuery));

I checked and the yii.debugtoolbar.js lib is installed under 'assets/84af4f51'. I also stepped through the php code and confirmed registerScriptFile() is being called for this file in YiiDebugToolbar.php.

Kind of stuck what's going on here. Is it a bug or is there some setup step I missed?

I'm running:

Yii 1.1.9

Thanks,

Peter

Сallback to debug toolbar

Needs to implement the possibility to make callback to debug toolbar bypass the application controller.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.