Xdump

Posted at 5:58 pm in development, php, projects

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
 

Written by Stefano Forenza on January 23rd, 2007

Leave a Reply