spiral/dumper

Colorful variable dumper

2.14.1 2022-09-01 21:12 UTC

README

Latest Stable Version Build Status Codecov

Dumper provides the ability to display the content of any given variable or object in a human readable form. Component support dumping into various outputs such as STDOUT, STDERR or log. Component support CLI colorization.

Usage

Installation:

$ composer require spiral/dumper

In your code (works in web and cli SAPIs):

use Spiral\Debug;

$d = new Debug\Dumper();

$d->dump($variable);

Dump to Log:

use Spiral\Debug;

$d = new Debug\Dumper($loggerInterface);

$d->dump($variable, Debug\Dumper::LOGGER);

Dump to STDERR:

use Spiral\Debug;

$d = new Debug\Dumper($loggerInterface);

$d->dump($variable, Debug\Dumper::STDERR);

Force dump to STDERR with color support:

use Spiral\Debug;

$d = new Debug\Dumper($loggerInterface);
$d->setRenderer(Debug\Dumper::STDERR, new Debug\Renderer\ConsoleRenderer());

$d->dump($variable, Debug\Dumper::STDERR);

Notes

  • component does not dump @internal properties
  • use __debugInfo() to specify custom set of data to display

License

The MIT License (MIT). Please see LICENSE for more information. Maintained by SpiralScout.