debugConsole with WordPress


For debugging inside of WordPress there are different approaches and preferences. I like xDebug and in some cases I use FirePHP. Now there is another possibility which I had to test at least once - debugConsole - I like it.

The debugConsole is a tool for debugging and tracing PHP5 applications on productive servers without compromising the live-traffic.

The features

  • access features
  • variable inspector
  • variable watches
  • replace PHP's errorhandling
  • timer clock
  • checkpoint management
  • and other features
    • filter events
    • log console output into logfiles additionally to or instead of the popup
    • configure dimensions and design of console window
    • color-coded events for quicker overview

So I created a little Plugin to play and test the console.
Currently I have only created a demo Plugin which shows the function. It won't be maintained, but can be downloaded here. As a small start and quick look at the possibilities I used the examples of the author of the debugConsole.

The Plugin has the following source code and you can add to any URL of the WP-installation the string ?debug=true, so that the popup called with the information of the console. Currently this is possible for frontend and backend.

<?php
/*
Plugin Name: debugConsole
Plugin URI: http://bueltge.de/
Text Domain: debugconsole
Domain Path: /languages
Description: The <a href="http://www.debugconsole.de/">debugConsole</a> 
is a tool for debugging and tracing PHP5 applications on productive servers 
without compromising the live-traffic. Add <code>?debug=true</code> to the URL for see 
the Popup-Window with debugConsole
Author: Frank B&uuml;ltge
Version: 0.1
Author URI: http://bueltge.de/
Donate URI: http://bueltge.de/wunschliste/
License: Apache License
Last change: 14.10.2010 11:30:51
*/ 

/**
License:
==============================================================================
Copyright 2010 Frank Bueltge  (email : frank@bueltge.de)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Requirements:
==============================================================================
This plugin requires WordPress >= 2.7 and tested with PHP Interpreter >= 5.2.9
*/
 
/* PHP5 required */
if (version_compare(PHP_VERSION, '5.0.0') < 0) {
	die('The debugConsole requires PHP 5.x.x or greater.');
}

/* load debugConsole functionality */
require_once 'debugconsole-1.3.0/debugConsole.php';

// add ?debug=true to the URL
if ( isset($_GET['debug']) && $_GET['debug'] == 'true') {
	add_action( 'wp_footer', 'wp_debug_console' );
	add_action( 'admin_footer', 'wp_debug_console' );
}

function wp_debug_console() {
	
	/**
	* debugConsole demonstration
	*
	* This script demonstrates each feature of the debugConsole. The
	* debugConsole is a PHP5 class using JavaScripts to show debug
	* information in a popup window. The popup has IP-based access
	* control. Configurate everything in debugConsole.config.php.
	* Additionally, PHP's default errorhandler is replaced.
	*
	* @author Andreas Demmer <mail@andreas-demmer.de>
	* @version 1.0.1
	* @package debugConsole_1.2.0
	*/
	
	/*
	Now you got an extended commandset:
	
	dc_watch()           watch variable changes in console
	dc_dump()            var_dump variables in console
	dc_here()            mark checkpoints in console
	dc_start_timer()     measure a timespan
	dc_stop_timer()      output timespan in console
	*/
	
	/* test watches */
	dc_watch('foo');
	
	declare (ticks = 1) {
		$foo = '1';
		$foo++;
		
		/* test checkpoints */
		dc_here('The interpreter passed through here!');
		
		/* test timer clock */
		$myTimer = dc_start_timer('Measure an one second sleep:');
		sleep(1);
		dc_stop_timer($myTimer);
		
		/* test variable debugging */
		$bar = 42.0;
		dc_dump($bar, '$bar tells us the meaning of life:');
		
		$foobar = array (
				'foo' => $foo,
				'bar' => $bar
		);
		
		dc_dump($foobar, '$foobar is a neat array!');
	
		/* test errorhandling */
		echo $notSet;
		fopen('not existing!', 'r');
	}
	
}
?>

Download as zip-file: debugConsole.zip - 131 kByte

Comments are closed.

9 comments

  1. chodorowicz

    the download link is broken

  2. Frank

    Thank you, now we has fixed the url; please dl now.

  3. Michael

    @chodorowicz: Thanks! It's fixed now.

  4. Rylie

    Can you please explain (further) this statement above: "... so that the popup called with the information of the console. Currently this is possible for frontend and backend."

  5. chodorowicz

    @Michael, @Frank: thanks for fixing it
    is it supposed to work also with Chrome? In FF the popup opens correctly but in Chrome nothing happens (you can see in Developer Tools all the additional scipts writing to the DOM but nothing pops up)

  6. Frank

    Why, is this not clear? Sorry, i dont understand your wish.

  7. Frank

    In my chromium works fine on a linux system.

  8. Ryan

    This is cool! This should make my work a lot easier especially with bugs.

    Thanks for sharing Frank. 😀

One pingback

  1. Weekly WordPress Review - WPCanada