We'll create fresh WordPress site with Debug Toolkit installed. You have 20 minutes to test the plugin after that site we'll be deleted.
Debug Toolkit makes debugging your code easier and more enjoyable. It provides you with interactive and helpful tools:
var_dump
, print_r
, or X-debugThe built-in PHP error container is basic and not as helpful as it could be. On top of that, it’s rather ugly. Wouldn’t you agree?
Whoops gives you a cool interface that is helpful, interactive, and quite nice to look at. Some features:
See the tools in action in this video
Though X-debug is powerful, it can be difficult to set up and run. For that reason, it’s common to dump or print out the variable to browser. But the built-in display for the PHP var_dump
and print_r
is basic.
This plugin includes both two very popular variable dumper tools:
VarDumper provides a simple container that displays where you place it.
On the other hand, Kint provides a more powerful interface that gives you more information such as printing out the expression that was passed into it, the data type, memory size, and the value.
To make it even easier, the following utility functions are available for you to use in your code:
Let’s explore the functions that are available for you through this plugin. We’ll use the variable inspectors to dump global $post
.
Note: You can pass in any variable or function that returns a value.
Dumps the given variable(s):
global $post;
// VarDumper
vdump( $post );
// Kint
dump( $post );
Dumps the given variable(s) and then exits the program’s execution:
global $post;
// VarDumper
vdump_and_die( $post );
// Kint
dump_and_die( $post );
In addition, there are alias (shorthand) functions available for you if you prefer shorter function names:
vd()
is an alias for vdump()
vdd()
and vdd()
are aliases for vdump_and_die()
d()
is an alias for dump()
dd()
and ddd()
are aliases for dump_and_die()
When debugging, there are times when you need to see the order in which functions were called that lead to a certain point in the program. PHP offers a backtrace that traces back the execution order from the point when the function is invoked.
To make backtracing easier, this plugin provides you with a trace()
function and combines it with the variable inspect functions.
For example, if you wanted to trace the call stack to the start of the loop in your theme’s functions.php
file, you could use this code:
add_action( 'loop_start', function() {
trace();
} );
Place these functions at the point where you want to trace the call stack.
trace();
trace_vdump();
– Combines trace()
and vdump()
trace_dump();
– Combines trace()
and dump()
trace_vdump_and_die();
– Combines trace()
and vdump_and_die()
trace_dump_and_die();
– Combines trace()
and dump_and_die()
In addition, there are alias (shorthand) functions available for you if you prefer shorter function names:
tracevd();
– Combines trace()
and vd()
traced();
– Combines trace()
and d()
tracevdd();
– Combines trace()
and vdd()
tracedd();
– Combines trace()
and dd()
tracevddd();
– Combines trace()
and vddd()
traceddd();
– Combines trace()
and ddd()
“DEBUG ACTIVE” indicator displays in the WordPress admin bar to alert you when the plugin is active.