Introducing the Scienta ZF Debug Bar
8 Jan 2009
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:
Clicking each of the sections short of the memory display will bring up a panel with more information:
- Current ZF version. Clicking will display Scienta Debug Bar version and copyright.
- View vars displays a panel with variables available to the view script
- Database queries and time. The panel shows complete SQL commands ready for copy-paste for tweaking
- Time to process the request from
$_SERVER['REQUEST_TIME']
to the Zend_Controller methoddispatchLoopShutdown()
is called. A click shows included files
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.