MadaConsole – A debug console for Zend Framework

Update: See my guide on How to make your own Zend Framework Resource Plugin

Building Facebook applications with Zend Framework, I’ve needed a debug console that can shows messages even in a Facebook canvas page, through an ajax request or a redirect.

For this purpose I’ve build a custom plugin for ZF that fits the need: it will sit under your pages and shows all your dumped object, messages and queries.

MadaConsole debug console
MadaConsole debug console

Usage is really simple: copy in your library and add the plugin in your Boostrap or application.ini.
For a detailed guide see below.

Features

  • Trace custom messages easily: debug("A debug message");
  • Dump variables easily in your code with the pass-through function:
    Before: array_count_values($arr); After: array_count_values(debug($arr));
  • Shows the queries executed by your Zend_Table
  • Shows debug messages even through redirects or ajax requests

Install

Installing the plugin is simple:

  1. Download the archive: MadaConsole
  2. Unzip the library folder of the archive in the library folder of your Zend Framework application

Then you can configure it with two methods: through your application.ini or in the Bootsrap class.

Method1: application.ini

Add those lines after [development : production]:

pluginPaths.MadaConsole = "MadaConsole"
resources.console = true

Method 2: Bootstrap class

Add this method:

public function _initConsole() {
     return MadaConsole_Console::initialize($this);
}

Usage

Now in your code you can do:

debug("A debug message");
debug($myArray);

$data = debug($myModel->findAll());
//It will recognize Zend_Db_* objects

With the pass-through functionality you can simply add the debug() function in your existing statements with ease: $var = debug(my_func($foo));

To see the debug output when you do an ajax request, you can open a page of your choice in another browser window: the debug console will show all the messages site-wide.

Downloads

MadaConsole plugin
MadaConsole example Zend Framework project

How the debug console looks like
How the debug console looks like

One thought on “MadaConsole – A debug console for Zend Framework

  1. Pingback: Os primeiros passos com Zend Framework « Diorgenes Felipe Grzesiuk

Comments are closed.