Descripción
Debug Toolkit hace que depurar tu código sea más fácil y agradable. Te proporciona herramientas interactivas y útiles:
- Better PHP error interface from (Whoops)
- Better variable inspection – no need to use
var_dump
,print_r
, or X-debug - An interactive way to back trace the program’s execution order
Better PHP Error Interface from Whoops
El contenedor de errores integrado de PHP es básico y no tan útil como podría ser. Además de eso, es bastante feo. ¿No estás de acuerdo?
Whoops te ofrece una interfaz genial que es útil, interactiva y bastante agradable a la vista. Algunas características:
- Provides the error message and links to search Google, DuckDuckGo, and Stack Overflow.
- Shows the actual code where the error occurred.
- Provides an interactive call stack. Click each and the actual code appears in the viewer panel.
- Environment and details including GET Data, POST Data, Files, Cookie, Session, Server/Request Data, Environment Variables, and Registered Handlers.
Mira las herramientas en acción en este video.
Better Variable Inspection
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:
Available Functions for Inspecting Variable Values
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 forvdump()
vdd()
andvdd()
are aliases forvdump_and_die()
d()
is an alias fordump()
dd()
andddd()
are aliases fordump_and_die()
Tracing Call Stack
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();
} );
Available Trace Functions
Place these functions at the point where you want to trace the call stack.
trace();
trace_vdump();
– Combinestrace()
andvdump()
trace_dump();
– Combinestrace()
anddump()
trace_vdump_and_die();
– Combinestrace()
andvdump_and_die()
trace_dump_and_die();
– Combinestrace()
anddump_and_die()
In addition, there are alias (shorthand) functions available for you if you prefer shorter function names:
tracevd();
– Combinestrace()
andvd()
traced();
– Combinestrace()
andd()
tracevdd();
– Combinestrace()
andvdd()
tracedd();
– Combinestrace()
anddd()
tracevddd();
– Combinestrace()
andvddd()
traceddd();
– Combinestrace()
andddd()
Admin Bar
El indicador “DEBUG ACTIVE” se muestra en la barra de administración de WordPress para alertarte cuando el plugin está activo.
Capturas
Instalación
Desde tu escritorio WordPress
- Visita ‘Plugins > Añadir nuevo’.
- Busca ‘Debug Toolkit’.
- Activa Debug Toolkit desde tu página de Plugins.
Preguntas frecuentes
- ¿Cómo utilizo esta herramienta?
-
Cuando estés probando o depurando tu código, puedes usar cualquiera de las funciones mencionadas arriba en lugar de var_dump( $var ) y print_r( $var ). No es necesario envolverlo en etiquetas pre.
- ¿Qué versión de PHP necesito?
-
PHP 5.6, 7.0, 7.1, 7.2, y superior.
- ¿Puedo ejecutar esto en un sitio en vivo?
-
No lo recomendaría a menos que estés realizando pruebas. Esta herramienta es solo para depuración. Una vez que publiques el sitio, desactiva y elimina este plugin.
- ¿Qué debo hacer cuando el sitio esté en vivo?
-
Desactiva y elimina este plugin.
Reseñas
Colaboradores y desarrolladores
Este software es de código abierto. Las siguientes personas han contribuido a este plugin.
ColaboradoresTraduce “Debug Toolkit” a tu idioma.
¿Interesado en el desarrollo?
Revisa el código, echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.
Registro de cambios
Version 1.0.1
- Removed changing the admin color palette.
- Removed changing the admin bar background color.
Version 1.0.0
- First release