Skip to content

Commit

Permalink
Add VarDumper collector docs
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Jan 6, 2024
1 parent da90fea commit addc9db
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions docs/en/collector/var-dumper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Collectors

## [VarDumper collector](./../../../src/Collector/VarDumperCollector.php)

`VarDumperCollector` collects all data dumped
by [`\Yiisoft\Yii\Debug\VarDumper\VarDumper`](https://github.com/yiisoft/var-dumper/blob/master/src/VarDumper.php) or
its shortcut functions `dump()`, `d` and `dd()`.

It uses [`\Yiisoft\Yii\Debug\Collector\VarDumperHandlerInterfaceProxy`](./../../../src/Collector/VarDumperHandlerInterfaceProxy.php) proxy to wrap the original VarDumper's [`HandlerInterface`](https://github.com/yiisoft/var-dumper/blob/master/src/HandlerInterface.php) and proxy all calls to the collector.

## Collected data

### Common

Example:

```php
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:

```json
[
{
"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

```json
{
"total": 3
}
```
1 change: 1 addition & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Main concept](./collector.md)
- [Summary collectors](./collector/summary.md)
- [Service Collector](./collector/service.md)
- [VarDumper Collector](./collector/var-dumper.md)

## Console commands
- [`debug:reset`](./command-reset.md)
Expand Down

0 comments on commit addc9db

Please sign in to comment.