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

Bills

Don’t forget to Subscribe

Latest Activity

Posts

  • Google this is ridiculous
    Google you’re doing it wrong. Very wrong. This is utterly ridiculous. It’s a screenshot with a standard Firefox browser, in the standard screen resolution (1280×800), on Read More
  • A step back from the open source
    One month ago, I created my first Android app. While the app was a paid one, the reception has been outstanding. I’ve gotten a fair amount Read More
  • Facebook shuts down EventPress development.
    When you’re a big company, especially one that makes its money on free web services and advertising, it’s very easy to say you love open Read More
  • Why Android is laggy
    Great post from Andrew Munn explaining some key differences between Android and iPhone/iOs, especially when it comes to rendering and smoothness of animations and why Read More
  • Google Plus keeps your data as much as Facebook does
    When you delete an account from Google+, Google promises you to delete all the data associated with your G+ profile. Well, I deleted mine some time Read More