hexmakina/debugger

Debugger is a PHP wrapper class for var_dump() output

Installs: 233

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 3

Type:package

0.1.4 2021-09-21 12:59 UTC

This package is auto-updated.

Last update: 2024-04-17 12:48:48 UTC


README

Latest Stable Version License

Scrutinizer Code Quality 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66363030336366613232646133323264376231392f6d61696e7461696e6162696c697479 PSR-4 Compliant PSR-12 Compliant PHP 7.0 Required

wrapper for var_dump, optional full stack trace, mandatory good looks

  • it tells you were the call was initiated so you don't ever have to look for a forgotten var_dump()
  • it shows you the trace of calls that lead to the dump
  • for each trace, it presents you with the filename, the class name and the function with params

no more wondering how a bug came into being.

Usage

Instantiate Debugger; to load the class and shortcuts

new \HexMakina\Debugger\Debugger();

Debugger class file has 2 namespaces, the debugger itself in HexMakina\Debugger, and in the root namespace, 4 shortcuts:

vd($var, $label);  // visual dump
dd($var, $label);  // visual dump AND die();
vdt($var, $label); // visual dump with full trace
ddt($var, $label); // visual dump with full trace AND die();

For instance, dumping the variable $foo, in file bootstrap.php, line 16, the output of vd($foo); would be:

**************
[bootstrap.php            16]       ?::vd(1627941733.4195)
string(4) "bar"

and the output of vd($foo, 'a label for easy spotting'); would be:

******* (a label for easy spotting) *******
[bootstrap.php            16]       ?::vd(1627942158.3575)
string(3) "bar"

but vdt($foo); would be:

**************
[index.php                 2]          ?::require(/var/www/dev.engine/koral/lareponse/koral/bootstrap.php)
[bootstrap.php            16]       ?::vdt(1627941924.2403)
string(4) "bar"

We now see the whole path the program took before reaching the debugging command

Deeper into the code, in a sub-sub-sub-sub-.. routine, the output of vdt($foo, 'inspecting foo'); would be:

******* (inspecting) *******
[index.php                35]  HexMakina\koral\Controllers\Home::bootstrap()
[Home.php                 28]  App\Controllers\Home::common_viewport(HexMakina\kadro\Controllers\Reception)
[Home.php                 18]  HexMakina\TightORM\TableModel::filter()
[TableModel.php          184]  HexMakina\koral\Models\Worker::filter(Array #0, Array #0)
[Worker.php               78]  HexMakina\TightORM\TightModel::filter(Array #0, Array #0)
[TightModel.php          160]  HexMakina\TightORM\TightModelSelector::__construct(HexMakina\koral\Models\Worker)
[TightModelSelector.php   20]  HexMakina\TightORM\TableModel::table()
[Crudites.php             31]  ::vdt(1631261380.9958)
string(6) "bar"

Easy debugging & old-school formatting, that's Debugger for you.