Xdump

When working with large arrays/objects,with complex references beetween variables or (again) php’s built-in var_dump() e debug_backtrace() shows their limits.

Have you ever tried to var_dump $GLOBALS ?

Even if when I started this lib there were already some classes which provided nice html formatted dump, in the moment I needed one, I couldn’t (my fault) find one.

Xdump started as a bunch of procedural lines of code and slowly evolved in a object-oriented library which can provide nice collapsable html dumps and backtraces, spoof references (to avoid dump bloat and recursions) and show source code lines where dump was invoked as well as display on screen source code lines for every backtrace jump.

Download

 

Xdump Download Page

Overview

Xdump let’s you display php vars nicely on the screen.

  • Jump to examples

  • Test cases are provided (requires SimpleTest)

Usage

 

  1. Include “xdump/xdump.php” in your main include file.

  2. Use following code:

echo xdump::dump($var);
  1. To show a backtrace instead type:

echo xdump::backtrace();

Samples

Dumping get_defined_vars() inside a Zen-Cart template

Licence and contact

 

  • Xdump is MIT Licensed.

  • Info, suggestions and stuff to: stefano@stefanoforenza.com

Features

General

  • Displays php dumps more nicely

  • Dumps are javascript contractible. They occupy little space on the page and open when clicked.

  • Display nicely without styles and javascript as well (if you work with them disabled)

  • Shows file, line number and source lines around the dump invocation (no more digging around to remove debugging code). Shows source lines for every backtrace jump as well (neat! try it).
  • (almost) Plug & Play

Technical

  • Handles reference recursions inside objects and arrays (no endless loop). Will signal visually nested references (the parent referenced element will blink orange).

  • PHP5 Overloading aware (doesn’t touch get, set etc)

  • PHP4 Compatible

  • Shows you backtrace info and the chunk of the code that invoked the dump

  • Some little effort to limit the size of markup inside the dump. Keep in mind that the dump will anyway be bigger than a vardump

This seems like a great time to subscribe my RSS !

2 responses to “Xdump”

  1. Andres Obrero

    very nice tool!
    if you set error_reporting(E_ALL|E_STRICT);
    you get a warning: Strict Standards: Non-static method xDump::dump() should not be called statically in …
    you should write
    static function dump()
    instead of just function dump()

  2. Stefano Forenza

    @Andres, thank you :-) . Well, believe or not, when xdump was written that warning still didn’t exist ;-)

Leave a Reply

Don’t forget to Subscribe

Bills

Latest Activity

Posts

  • What is Google ChromeOS, I mean really ?
    All this fuss about Google ChromeOS. Is it a threat to Microsoft ? Is it a threat to the Ubuntu ? (funny nobody wonders if that’s Read More
  • Well said Carla !
    Carla has something to say ’bout the cloud, and I agree 100% with her. Share it !
  • No more Gimp for you little Joe
    When I first posted about the matter, most people’s reaction was LOL. The we thought it was just a random proposal, never going to be Read More
  • Custom iTunes page generator
    Who never dreamed to have his personal Apple website page, like this guy ? Now you can ! UPDATE : they just fixed the page, Read More
  • Fedora's new little friend
    Straight from the release notes of the recently released Fedora 12: Gnote is installed by default in GNOME for this release replacing Tomboy. Gnote is a port Read More