Debug - Dumping Variables

Use Spirl\Debug\Dumper class or function dump to view content of your variables and instances without xDebug:

protected function indexAction(Dumper $dumper, MemcacheStore $memcacheStore)
{
    $dumper->dump($memcacheStore);
}
protected function indexAction(MemcacheStore $memcacheStore)
{
    dump($memcacheStore);
}

Dump

The Spiral Dumper supports the __debugInfo method which allows you to dump only important information.

Usage

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);

You can use function dump as a shortcut. Use dumprr to dump to RoadRunner error log.

Internal Fields

To hide certain fields of your objects without __debugInfo method, add an "@internal" annotation to your property.

class TestService
{
    /**
     * @internal
     * @var ContainerInterface
     */
    protected $container = null;
}

In RoadRunner

You can dump variable into roadrunner debug log using function dumprr. Make sure to use this function in your job handlers.

Edit this page