A PHP Developer's Blog - Joakim Nygård

About jokke.dk

jokke.dk is the personal website of , a software architect, entrepeneur and Mac user living in Copenhagen, Denmark. Read more »

Search the Site

Recent Posts

Popular Posts

Introducing the Scienta ZF Debug Bar

7th January, 2009  |  107 Comments

Update: There's a new blog post with details on version 1.4.

Since the early betas I've been using the Zend Framework in several professional and personal PHP projects with great joy. To aid the development process, I decided to build an easy to use debug panel. This first version requires the Zend MVC paradigm as it is implemented as a Zend_Controller_Plugin.

The Scienta ZF Debug Bar injects into every request a snippet of HTML with commonly used debug information. Time spent, memory usage and number of database queries are presented at a glance. Additionally, included files, a listing of available view variables and the complete SQL command of all queries are shown in separate panels. Combined, I believe it can cut down on the number of debug output statements like var_dump while developing - I know it did for me.

The output is a simple bar in the lower left corner of the browser window:

2009 Scienta Debug Bar

Clicking each of the sections short of the memory display will bring up a panel with more information:

To install, place the folder 'Scienta' in your library path, next to the Zend folder. Then add the following lines to your bootstrap file:

$scBar = new Scienta_Controller_Plugin_Debug(array(
            'database_adapter' => $db, // Zend_Db_Adapter_Abstract
            'memory_usage' => true,
            'collect_view_vars' => true));
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin($scBar);

The constructor options array is optional and allows for disabling specific panels, e.g. if no database adapter is presented, the query section and panel will not be shown. More info and download Scienta ZF Debug Bar here.

This release is the first public version. As such there is surely bugs and clever features missing. Never the less, I hope it will make for a somewhat faster development process - let me know.

Update As several readers have pointed out, the look of Scienta Debug Bar is very similar to the Symfony Framework. The icons are from the excellent Silk Set by Mark James - also used by Symfony.

« One Application to Rule Your Files  –  A New Look »

107 Comments

ask

8th January, 2009

Superfedt :) glæder mig til at kigge nærmere på den.

Jeg ku' forestille mig en option så debuginfo bare blev outputtet til FireBug (ligesom FirePHP) ville være smart.


[MA]Pascal

8th January, 2009

No credits to original author ?


NiKo

8th January, 2009

Reminds me somthing symfony-related... anyway, that's a nice feature


Michel Bertier

8th January, 2009

nice work, would have been nice to credit appropriate people though...

django people seem to be more polite than ZF coders :P

http://rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/


Stefan

8th January, 2009

Good to see the symfony toolbar making it to Zend Framework!


Joshua May

8th January, 2009

That's definitely something I know a lot of developers (in other languages, too) would like to see, and have been somewhat jealous of symfony for a while now!

Nice to see someone doing something productive with it.

Credit, of course, where credit is due though..


Eric

12th January, 2009

Definitively a VERY nice feature !

Maybe it could be improved in some way :
* Add controllers timings (via preDispatch/postDispatch)
* Plugable output (FireBug, plain html, ...)

I also hope it will find is way in Zend Framework core :)

Thanks for it !


eMeRiKa

7th February, 2009

Thanks you !

It is possible to use two database_adapters with your debug bar ?


M4d3L

11th February, 2009

Very nice tool. I will integrate to my work.

any possibility to add easy positionning config?

where we can config an array like

array(
'top' = '5px',
'bottom' = '',
'left' = '',
'right' ='5px'
)

so this will put the bar in the top right


M4d3L

19th February, 2009

Nice I just have try your last version. it is more fast now. I want to include your work as an official plugin of my new Portal system build on ZF. I some idea for this plugin. Like to catch Firephp information send to client for who making test in IE or other navigator that doesnt have firebug plugin installed like on Safari Iphone.

You will find here information about my portal system here - http://code.google.com/p/phenixzps/
Am working on cleaning the code and add comment then I will release the experimental code.



dizi izle

21st February, 2009

Nice Write Thank You mate.. i think i will like this site.

dizi izle
dizi seyret


umpirsky

30th March, 2009

Nice job!

TODO:

Make debug bar XHTML valid (this is important)
Use self:: instead className::


Hugo

30th March, 2009

Nice symfony feature :)


gabriel solomon

30th March, 2009

hello,

a very cool plugin. But i have a little bug with it :(
it crashes my prototype scripts :(


Keith

30th March, 2009

Hey there, I tried running it on my site and got a really wacky error. If I view source, I see this line:



If I view compiled source (FF web dev toolbar) I see this:

<style type=" text="" css="" media="screen"

Looked into it for a few minutes, but didn't see anything out of the ordinary. No idea what's doing that. Guesses?


Gerard Roche

31st March, 2009

Very nice, two suggestions:

1. An Included files count

Included files ({COUNT})
... files included ...
... files included ...


And

2.

Add a pointer to the cursor in CSS when hovering on action buttons http://reference.sitepoint.com/css/cursor.



Gerard Roche

31st March, 2009

@umpirsky

I agree, this is very important.

XHTML STRICT valid.


Joakim Nygård

31st March, 2009

Thanks for all your feedback :)

The plugin output should definitely validate. There are however many problems with XHTML, particularly that IE does not support files transfered as application/xhtml+xml. Transfering as text/html is allowed but will not trigger any xml wellformed checks.

Also see http://codinginparadise.org/weblog/2005/08/xhtml-considered-harmful.html

The next version will be HTML4 Strict valid.

I will also add the suggested pointer cursor and a count on included files. The new version should be ready in a few days.


Jonathan Persson

31st March, 2009

Really nice! Thanks!


Nicolas H

1st April, 2009

Nice and useful!

Note that the "view vars" functionality uses the "getVars()" method of the view object, which is not present in the Zend_View_Interface. So, if you use an alternate template engine (like explained in http://framework.zend.com/manual/en/zend.view.scripts.html#zend.view.scripts.templates.interface), you have to add the "getVars" method.

For example, with smarty :

class Class_View_Html extends Smarty implements Zend_View_Interface {
...
public function getVars() {
return $this-get_template_vars();
}
}


Kaffee

2nd April, 2009

How about support for $_COOKIE, $_SESSION, DOM-Elements (document.getElementsByTagName("*").length) and code execution coverage (with xdebug)? :)


alberto

2nd April, 2009

anyone has some ideas to use sql debug using doctrine?


Ben

2nd April, 2009

Added Doctrine support:
http://php.pastebin.ca/raw/1379134


alberto

3rd April, 2009

Thanks Ben


darookee

26th April, 2009

Added Zend_Registry memory usage display when clicking on the memory tab:
http://rafb.net/p/6jH6sH67.html


Jurian Sluiman

12th May, 2009

I have altered the debug bar. The constructor calls now the public method setOptions(). This method contains the constructor contents except for the timer. On request I can send you the patch.

Now it is possible to load the debug bar with your application.ini. Anywhere you want to setup the options (for me, the database_adapter) it is possible to do it elsewhere. The application.ini has no possibility to add these options, so I bootstrap them with the new setOptions() method. The control of enabling the plugin stays nevertheless in my application.ini.


Paul Parenko

18th May, 2009

$options = array(
'database_adapter' = $this-getPluginResource('db')-getDbAdapter(), // or array of adapters
'memory_usage' = TRUE, // default value shown
'collect_view_vars' = TRUE,
'sort_view_vars' = TRUE,
'show_exceptions' = TRUE,
'handle_errors' = FALSE,
'execute_tests' = TRUE,
'tests_path' = array(APPLICATION_PATH.'../tests'),
'tests_list' = array('BootstrapTest'),
'tests_place' = array('controller' = 'Index',
'action' = 'Index',
'test' = 'on'),
);

$scBar = new Septem_Controller_Plugin_Debug($options);
$frontController = Zend_Controller_Front::getInstance();
$frontController-registerPlugin($scBar);


Paul Parenko

18th May, 2009

Sorry but I forgot the text:
How about showing tests (PHPUnit) if they are successful or not with Scienta ZF Debug Bar?
And the options could contain the path to the unit-tests (or many in an array), permission to make tests, the place where the tests should be execute.

i.e. see upper


Phillip Winn

19th May, 2009

I really, really, really don't get how anybody has DB stuff this early in the startup. People configure their DB adapters before even dispatching to the front controller? Really?


Joakim Nygård

20th May, 2009

@Phillip Winn:

The latest version in svn (v1.5) has been rewritten to allow easier customization.
With this it is possible to load plugins after the ZFDebug bar has been registered with the front controller.

$zfdebug = Zend_Controller_Front::getInstance()->getPlugin('ZFDebug_Controller_Plugin_Debug');
$zfdebug-registerPlugin(new ZFDebug_Controller_Plugin_Debug_Plugin_Database($optionsArray));

This can be done at any point before dispatchLoopShutdown().


SLIM

3rd July, 2009

ZFDebug\Controller\Plugin\Debug.php
[php]
protected function _output($html)
{
$response = $this-getResponse();
$response-prependBody($this-_headerOutput() . ''.$html.'');
}
[/php]
and add options (append or prepend)

it's will be likely


SLIM

3rd July, 2009

sorry the site cut meny tags, but i hope that your understand my fix


a?k mesajlar?

17th July, 2009

Thanks you !

It is possible to use two database_adapters with your debug bar ?


ask mesajlari

17th July, 2009

Thanks you !

It is possible to use two database_adapters with your debug bar ?


Joakim Nygård

17th July, 2009

Hi,

It is indeed possible to use two database adapters. Just pass them as an array like so:

[...]
'database_adapter' = array('adapter' = array($db1, $db2))
[...]


lazer epilasyon

10th September, 2009

Do you have some example code?


sesli siirler

9th October, 2009

anyone has some ideas to use sql debug using doctrine?


Snowcore

3rd December, 2009

Thats really useful plugin! Thanks!
Now I am using it in all of my projects :)


Cialis

18th December, 2009

When I open your site in your browser, Safari 4 in Mac OS X, some elements of the page and off to the side and the text is broken: ( Please help me How can I remove the problem?


zoo coupons

30th January, 2010

great info thx


stop snoring

15th February, 2010

Great tool. Thanks for sharing this nice post.


Dollarkurs

13th March, 2010

It is possible to use two database_adapters with your debug bar ?


Medyum

16th March, 2010

It is possible to use two database_adapters with your debug bar ?


Cem

19th May, 2010

good tool thanks that you published for us


liseli

20th May, 2010

Thank you.


estetik

23rd May, 2010

Nice I just have try your last version. it is more fast now. I want to include your work as an official plugin of my new Portal system build on ZF. I some idea for this plugin. Like to catch Firephp information send to client for who making test in IE or other navigator that doesnt have firebug plugin installed like on Safari Iphone.


ClubPenguinCheats

24th May, 2010

The plugin output should definitely validate. There are however many problems with XHTML, particularly that IE does not support files transfered as application/xhtml+xml. Transfering as text/html is allowed but will not trigger any xml wellformed checks.


Turksex

11th June, 2010

Thank you.


mu?la datça

11th June, 2010

As you have a blog about sharing was very nice.
I host it and different places in search of an active subject.
I thank you for information.


cam mozaik

15th June, 2010

Thanks administrator.. Powerfull blog good research.


Türkporno

16th June, 2010

thanks you admin for job


porno izle

20th June, 2010

Thanks for post.


lazer epilasyon

21st June, 2010

Laser Hair Removal Methods


estetik

21st June, 2010

Thank you very much very nice article
Great information! Very useful for me. Thanks a lot.
The idea is awesome. Congrats.


Private Server

23rd June, 2010

thanks you for post admin


dizi izle

23rd June, 2010

deneme deneme


siki?

23rd June, 2010

siki?
sex
sex
porno izle
siki?
porno izle
porno izle
porno


siki?

23rd June, 2010

siki?
sex, porno izle
sex
porno izle
siki?
porno izle
siki? izle, porno izle
porno, porno izle


dizi izle

27th June, 2010

Thank you admin nice blog


video izle

27th June, 2010

thank you admin.


D?? cepheler

3rd July, 2010

As you have a blog about sharing was very nice.
I host it and different places in search of an active subject.


cam mozaik

12th July, 2010

As you have a blog about sharing was very nice.
I host it and different places in search of an active subject.
Ithank you for information.


estetik

12th July, 2010

Thank you very much very nice article


lazer epilasyon

14th July, 2010

This site contains extensive information about laser hair removal and expertise based on scientific data has been prepared by specialists . Which type of laser hair removal is right for you to get an idea of where we want to .


safety valve

17th July, 2010

This is a great article, supplies the useful information for me, thanks in this
pressure relief valve|forged Steel valve|butterfly valves|dustbin


Mesothelioma

21st July, 2010

It same as .net frame work or change???


dizi izle adanali

30th July, 2010

tenks


ev dö?e

30th July, 2010

tenks


travesti

3rd August, 2010

thnk you


tüp bebek

3rd August, 2010

thank you tup bebek


estetik

3rd August, 2010

thank you very nice
Sac Ekimi
Notebook Servisi


konteyner

4th August, 2010

Notebook Servisi konteyner


porno izle

4th August, 2010

Thanks for posting. I think Daniel Pink presentation is really clear, and fun, and useful.


tupbebek

9th August, 2010

was an article I liked. Thanks for sharing.
...


prefabrik

10th August, 2010

I liked. Thanks for sharing.prefabrik


prefabrik evler

12th August, 2010

nevyap.com


New England Aquarium Coupons

12th August, 2010

that's very good info
i think i will put some my own blog :D
cheers


dikkatdizi

13th August, 2010

good,thank you


film izle

17th August, 2010

thank for sharing


error fix

17th August, 2010

nice to credit appropriate people though...

django people seem to be more polite than ZF coders :P


kabin

18th August, 2010

? 29 ???. ? ?????? ????????? ???? ?? ?????
??? ?? ?????? kabinler


gavur

19th August, 2010


sex
sex, msn canl? show
Sex Shop, K?rm?z? shop mersin
Eczanemx mersin adana tarsus kozmetik penis büyütücü zay?flama Cabbage Pow



lazer epilasyon

20th August, 2010

Current ZF version. Clicking will display Scienta Debug Bar version and copyright.


Hurda

20th August, 2010

I think type of site that is useful in sharing information and it is important to shar.


travesti

20th August, 2010

Eczanemx mersin adana tarsus shemale in google


travesti

20th August, 2010

Post thank you


travesti

20th August, 2010

nice to credit appropriate google


travesti

20th August, 2010

was an article I liked. Thanks for sharing post thank


Hali Yikama

21st August, 2010

Thanks admin


james blunt

21st August, 2010

thanks admin!! best information!!
Get Promoted


siki?

23rd August, 2010

Thanks admin


Buz

23rd August, 2010

admin thanks


Moosejaw Coupons

23rd August, 2010

very nice info
very good article
very good blog


su deposu

24th August, 2010

Eczanemx mersin adana tarsus kozmetik penis büyütücü zay?flama Cabbage Pow


porno izle

24th August, 2010

where thank you older


porno izle

24th August, 2010

where the you olde rpost


jordan 1

25th August, 2010

dsafhadfgh


Konteyner

26th August, 2010

A significant share of your site as people think. Thank you.


travesti

26th August, 2010

Thnks good job.


james blunt

27th August, 2010

thank you!!


SeksTurk

29th August, 2010

thank you admin!!


tar?k

29th August, 2010

very good güzel


prefabricated

31st August, 2010

???...?? ??? ???????? ??? ??????? ??????


Web Tasarim

31st August, 2010

thanks for sharing web design


Dell Destek

1st September, 2010

I wish you continued success sharing.thanks


travesti

1st September, 2010

You plans obi year


porno izle

1st September, 2010

older post you nice admin


Post A Comment

You need JavaScript to post comments.