Maybe you're interested About this site or in some of my Projects or Articles. You might even be interested About me or My Friends. If all else fails head back Home.

Morethanseven is where plays with the web

Nice bits of symfony: Web Debug Toolbar

December 26th, 2007

I mentioned previously that I’d been playing with the symfony framework on a couple of projects and I have to admit to being more and more impressed as I wade in looking for things. I’ve worked with enough MVC-like frameworks to know they are all quite similar in more ways than they are dramatically different. So it’s the little bits and pieces that win you over.

One of my favourite little bits in symfony has to be the Web Debug Toolbar. When running in development mode you get a little menu floating above your application like so (top right hand corner).

Web page showing the symfony web debug toolbar in the top right corner

This gives you all sorts of useful information as you’re developing your application – from the number of database queries to the rendering time, with a full logger built in. It’s also been particularly useful in learning symfony – being able to follow the entire request through the stack from the logger is really handy when you don’t know what is going on.

Web page showing the symfony web debug toolbar fully expanded

With the increasing use of object relational mapping in web frameworks it’s quite easy to end up with a working application on your development box that turns out to absolutely hammer your database when used in the real world by only a few hundred people (I’m looking at you tagging). The database utilities, showing the number of queries and the SQL for those queries, is particularly handy for finding bottlenecks here.

Web page showing the symfony web debug toolbar SQL view

I’ve not come across something similar in other frameworks, PHP or otherwise. I’d be interested to know if similar things do exist for Rails or Django in particular.

Popularity: 10%

Tagged , , ,

3 Responses to “Nice bits of symfony: Web Debug Toolbar”

  1. This is definitely a nice thing in Symfony with the “toolbar” being a feature of symfony.

    I can’t remember rails but CakePHP in “dev” or “debug” mode shows pretty much the same debug messages although I have to admit they are neither so prettily formatted nor unobtrusive. However, that is just a matter of some CSS and Javascript trickery on the debug div.

    What is interesting though is looking at the log in the first image, the symfony framework seems to be modelled on the Java servlet + Struts based model where you have a Contextthat handles a Request that passes through Filters and is then handled by a Action and finally rendered by a View. Very interesting from our perspective as daily Struts 2 users. Symfony might be an easier leap for us than CakePHP and certainly something worth looking into for us.

  2. CodeIgniter has a sort-of debug mode (triggered by calling a method in the controller) that spits out a nicely formatted list of stack calls and queries at the bottom of the page – like you say, it’s useful when you’re trying to track down database bottlenecks (although the logging class is great too, if you can run that in Terminal when testing).

  3. [...] tracing tools, a couple of frameworks have their own, more or less specific, tools. Symfony’s Debug Toolbar is probably the most impressive (And in contrast, Zend Framework the least), even providing [...]

Leave a Reply