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.
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"
}
]
{
"var-dumper": {
"total": 3
}
}