MadaConsole – A debug console for Zend Framework

Posted in PHP at 11:32 am by Madarco  

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:

PHP:
  1. public function _initConsole() {
  2.      return MadaConsole_Console::initialize($this);
  3. }

Usage

Now in your code you can do:

PHP:
  1. debug("A debug message");
  2. debug($myArray);
  3.  
  4. $data = debug($myModel->findAll());
  5. //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

1 Comment

  1. [...] desses novos recursos na minha aplicação vários erros surgirão, então descobri um plugin bacana e fácil de instalar e utilizar, que exibe erros, sql, dump de variaveis ou array de uma forma [...]

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.