Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 1.43 KB

var-dumper.md

File metadata and controls

60 lines (49 loc) · 1.43 KB

VarDumperCollector collects all data dumped by \Yiisoft\Yii\Debug\VarDumper\VarDumper or its shortcut functions dump(), d(), and dd().

It uses \Yiisoft\Yii\Debug\Collector\VarDumperHandlerInterfaceProxy proxy to wrap the original VarDumper's HandlerInterface and proxy all calls to the collector.

Collected data

Common

Example:

final class SiteController
{
    public function __construct(private ViewRenderer $viewRenderer)
    {
        $this->viewRenderer = $viewRenderer->withController($this);
    }

    public function index(): ResponseInterface
    {
        d(['test'], 1, new stdClass());
        return $this->viewRenderer->render('index');
    }
}

Output:

[
    {
        "variable": [
            "test"
        ],
        "line": ".../demo\/blog\/src\/Controller\/SiteController.php:20"
    },
    {
        "variable": 1,
        "line": ".../demo\/blog\/src\/Controller\/SiteController.php:20"
    },
    {
        "variable": "object@stdClass#7735",
        "line": ".../demo\/blog\/src\/Controller\/SiteController.php:20"
    }
]

Summary

{
    "var-dumper": {
        "total": 3
    }
}