Skip to content
/ jdump Public
forked from mathiasverraes/jdump

J!Dump is a very easy to use debugging extension for Joomla developers and template designers. Download links below.

Notifications You must be signed in to change notification settings

garstud/jdump

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

J!Dump README

Advanced print_r and var_dump replacer with object tree display.

Features

This utility makes life easy for developers and template designers. You use it to see what's inside a variable, an array or an object. Instead of using print_r() or var_dump(), you can now use dump(). This will open a popup window with a nice expandable tree, showing the contents of the variable. It will even show a list of available methods for each object. You have to see it to believe it! You can use dump() in your extensions, in the core, in libraries and even in templates.

Warning! This component is only meant to be used on development test sites, NOT in live or production environments. If you must use it on a live site, don't do stupid things like dump($password) !

Download

Installation

Since 1.2.2 just install the package file (pkg_jdump_v*.zip). It will automatically install and publish JDump component and plugin.

If you don't want the dump popup window to appear automatically, you can disable it in the configuration. To display the dump window manually:

  • Administrator: Go to Components -> J!Dump and click Popup.
  • Site: Make a new menu item for J!Dump. Set it to 'Open in New Window'

Using J!Dump

Anywhere in your code, type:

dump($variable, 'Variable Name');

Simple huh? 'Variable Name' is optional and can be anything you like. If you use a lot of dumps, you'll want to use some descriptive names.

Shortcuts

// Displays a whole bunch of system information.
dumpSysinfo();

jdump-shortcut1

// Use inside a template's index.php to dump the parameters.
dumpTemplate($this);
// Displays a custom message. Very handy to check if a function or a loop is executed etc...
dumpMessage('Your message');

jdump-shortcut1

// Displays the backtrace.
dumpTrace();

jdump-shortcut1

Notes

You can't use dump() in system plugins that are run before the J!Dump plugin is run, so it is best to use ordering in the plugin manager to put J!Dump upfront.

J!Dump requires at least Joomla 2.5.5. If you need compatibility with an older version of J!Dump, please download v2012-10-08.

JDump Tips

Tip 1:

You want to be sure that your web site won't show a fatal error if you forget to remove a dump trace in your code, before running in production ?

In that case, you can add an IF test with 'if(function_exists("dump"))' just before calling "dump()". If the JDump plugin is uninstalled or unpublished, the dump() method will not be called :

// ensure dump() is accessible
if(function_exists("dump")) dump($myVar, "My Var is");

You can also complete this sentence by adding the class name, function and line number using this syntax:

// ensure dump() is accessible and show class, function and line number
if(function_exists("dump")) dump($myVar, __CLASS__."::".__FUNCTION__."(#".__LINE__.") My Var is");

This will show :

jdump-complete_label_syntax

Tip 2:

If you want to dump an SQL query of a Query Object, JDump won't show anything ! ... you have to use the magic method __toString() :

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, name, email');
$query->from('#__users');
$query->order('username DESC');

// display the content of an SQL query
if(function_exists("dump")) dump($query->__toString(), "My SQL query to read users");

This will show : "SELECT id, name, email FROM #__users ORDER BY username DESC"

Note: If your SQL query is too long, maybe JDump will cut the display. You can change the length of a variable in the dump window by changing the parameter of the JDump component in admin called "Maximum String Length".

Tip 3:

You want to get the file path of a PHP script that contains a specific object ? You can use the implemention of the Reflection process (native PHP 5). Execute the Reflection process on the name of the class set in parameter (ex : JModuleHelper). Call the JDump method getFileName() method on the resulted object and it's done !

// get the path of a PHP script class
$ref = new ReflectionClass('JModuleHelper');
if(function_exists("dump")) dump($ref->getFileName(), 'Reflection Class path for '.$ref->getName());

This will show :

jdump-reflection_class

Troubles?

You find some issues with this specific version of JDump? Ok, go and post a commented issue, i will have a look and try to help you ;)

Originals Contributors

  • Mathias Verraes (Lead)
  • Jens-Christian Skibakk
  • Tom Fuller
  • Thomas Hunziker

Thanks to everybody who provided patches!

License

J!Dump is licensed as GNU/GPL v2.

Credits

This component includes Folder Tree Static by Alf Magne Kalleland. It is released under LGPL and can be found at http://www.dhtmlgoodies.com/

About

J!Dump is a very easy to use debugging extension for Joomla developers and template designers. Download links below.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 37.0%
  • JavaScript 36.1%
  • CSS 26.2%
  • HTML 0.7%