Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

 

Debugging like a pro

Bugs, bugs, everywhere. How do you get rid of them? Here's a module that can help you debug like a pro.

Read post

SilverStripe CMS/Framework in itself has quite a toolset available for debugging, like Debug::dump(); and the URL parameters, but they’re rendered at the top of the page, which may not be ideal. You might have some fixed or absolute positioned items like a menubar, obfuscating part of the output.

There’s also your IDE with XDebug. But sometimes, that can be overkill. You don’t always want to halt the process, just for reading the request parameters, let alone dump them into the page and then accidentally forget to remove them later.

Recently, I stumbled upon a new little project by Thomas, better known as Lekoala, who built the first version of a DebugBar. Some of you might work with Symfony2 or Laravel and know about the large debugging option they give in-browser when they’re enabled.

DebugBar adds a little nice window below your website, containing a lot of information. Most helpful, I found, is the Database, which gives you all the executed queries (works with PDO only).

image01

Request

Want to know your request parameters? Look no further. All parameters are included, and can optionally be expanded, with color highlighting. Even JSON cookies work just fine and are nicely highlighted:

One thing I would like to see here would be the URL split into the Params as the Controller provides them. But you can’t have everything on the first go, right?

The useful thing about having the request this verbose means you can easily debug your post and/or request actions, without having to revert to the debugger just to see the variables. Overall, a nice addon to the features SilverStripe already has.

Timeline

This is mostly a shortened version of the request measurer from most default tools already installed in the browsers, with the main difference showing a shortened version of the internal request process, and how long they take:

timeline

Mind you, this is on my local little machine—not really a fast machine. But it shows that most is taken up by my own controller. Apparently, I have to fix some issues there?

Exceptions

Let’s hope you never run into them. But if they are there, you’ll see them. But since PHP already kicks the bucket when it runs into an exception, it’s a bit of a double-up.

Database

My favorite. I always try to kick down the amount of DB queries executed. And having an overview of the queries with the parameters is awesome. ?showqueries=1 works, but it’s not as detailed as the PDO output itself.

Although this only works with the PDO driver, it’s extremely useful. It tries to identify duplicate queries as well. Although admittedly, they’re often not really duplicates, but a duplicate query with different parameters.

database debug

I believe this is a very useful feature!

Config

An overview of your SiteConfig variables that are loaded. Although you should already know them, it’s not bad to show how big your SiteConfig is getting. And it made me slim down my SiteConfig quite a bit!

config debugThat’s it for now—another useful SilverStripe module to help you get on the way.

Oh yes, the folder-icon. That’s for searching history it seems, but I can’t get it to work (uh-oh). I guess I’m doing it wrong? Compu’er says no.

So, if you are looking for some extra development tools on top of the already available tools, or just feel like some more coding, get the module, play around with it, and of course, don’t forget to contribute.

About the author
Simon Erkelens

Simon is a developer at SilverStripe. When not at work, he's writing other programs or focusses on one of his modules he wrote or co-wrote. Or writing new things.

As a real backend developer, he's usually staring at a dark screen with code only. Although every now and then, he can be convinced to work on some frontend things or testing.

In real life, he looks nothing like the cow in his avatar, but he does love cows (both alive and medium rare)

Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments

Like what you have read?

Sign up for our weekly blog digest sent to your inbox.

Subscribe