# DumpCollector

> Captures the values dumped through yiisoft/var-dumper during the request for the Dump panel.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Collector](/docs/extensions/yii3-debug/reference/collector/index.md) › DumpCollector

| final class | `Yii3\Debug\Collector\DumpCollector` |
| --- | --- |
| Implements | [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php) |
| Source | [`src/Collector/DumpCollector.php`](https://github.com/yii3/debug/blob/main/src/Collector/DumpCollector.php#L34) |

Captures the values dumped through `yiisoft/var-dumper` during the request for the Dump panel.

Yii3 has no `Yii::debug()`, so the capture point is the var-dumper default handler: [`startup()`](/docs/extensions/yii3-debug/reference/collector/dumpcollector/index.md#method-startup) decorates it with
a [`DumpHandlerProxy`](/docs/extensions/yii3-debug/reference/dump/dumphandlerproxy/index.md) and [`shutdown()`](/docs/extensions/yii3-debug/reference/collector/dumpcollector/index.md#method-shutdown) puts it back. Each dump is recorded in the logger-tuple shape the
Yii2 collector produces (trace level, `application` category, call-site frame), so a capture written by either host
renders through the same [`DumpCardRenderer`](https://github.com/php-forge/debug-core/blob/53c259241281d3275cd5cbfa64f08eb986d6bce3/src/Panel/Dump/DumpCardRenderer.php).

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`capture()`](#method-capture) | Encodes the captured dumps into the Dump panel payload. | `DumpCollector` |
| [`collect()`](#method-collect) | Records one dump, pre-rendered the way the application output shows it. | `DumpCollector` |
| [`id()`](#method-id) | Returns the stable identifier of this collector. | `DumpCollector` |
| [`shutdown()`](#method-shutdown) | Stops capturing, clears the recorded dumps, and restores the var-dumper default handler. | `DumpCollector` |
| [`startup()`](#method-startup) | Starts capturing by installing a [`DumpHandlerProxy`](/docs/extensions/yii3-debug/reference/dump/dumphandlerproxy/index.md) around the current var-dumper default handler. | `DumpCollector` |

## Method details

### capture() <span id="method-capture"></span>

```php
public function capture(): array<string, mixed>|null
```

Encodes the captured dumps into the Dump panel payload.

**Returns**

`array<string, mixed>|null`: Encoded Dump panel payload; `null` when the collector never started.

### collect() <span id="method-collect"></span>

```php
public function collect(mixed $variable, int $depth, bool $highlight, list<Yii3\Debug\Collector\TraceFrame> $trace): void
```

Records one dump, pre-rendered the way the application output shows it.

The value is rendered with the depth and highlighting the caller requested: highlighted output is the markup
var-dumper's [`EchoHandler`](https://github.com/yiisoft/var-dumper/blob/0860637f99fddfbeb98976bcc716b2aabc94ff85/src/Handler/EchoHandler.php) prints, which the Dump card keeps; plain output is HTML-encoded, as the Yii2
collector does, because the card renders the message as markup.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$variable` | `mixed` | Dumped value. |
| `$depth` | `int` | Maximum nesting depth requested by the caller. |
| `$highlight` | `bool` | Whether the caller requested syntax-highlighted output. |
| `$trace` | `list<Yii3\Debug\Collector\TraceFrame>` | Call-site frame of the dump, or an empty list when unknown. |

### id() <span id="method-id"></span>

```php
public function id(): string
```

Returns the stable identifier of this collector.

**Returns**

`string`: Stable ID pairing this collector with its panel.

### shutdown() <span id="method-shutdown"></span>

```php
public function shutdown(): void
```

Stops capturing, clears the recorded dumps, and restores the var-dumper default handler.

The previous handler is restored only while the proxy is still the default, so a handler the application
installed during the request is kept; a proxy left in its chain forwards without recording.

### startup() <span id="method-startup"></span>

```php
public function startup(): void
```

Starts capturing by installing a [`DumpHandlerProxy`](/docs/extensions/yii3-debug/reference/dump/dumphandlerproxy/index.md) around the current var-dumper default handler.