# DumpHandlerProxy

> Intercepts yiisoft/var-dumper dumps to feed the DumpCollector, then forwards each dump unchanged.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Dump](/docs/extensions/yii3-debug/reference/dump/index.md) › DumpHandlerProxy

| final readonly class | `Yii3\Debug\Dump\DumpHandlerProxy` |
| --- | --- |
| Implements | `Yiisoft\VarDumper\HandlerInterface` |
| Source | [`src/Dump/DumpHandlerProxy.php`](https://github.com/yii3/debug/blob/main/src/Dump/DumpHandlerProxy.php#L31) |

Intercepts `yiisoft/var-dumper` dumps to feed the `DumpCollector`, then forwards each dump unchanged.

[`DumpCollector::startup()`](/docs/extensions/yii3-debug/reference/collector/dumpcollector/index.md#method-startup) installs the proxy as the var-dumper default handler, so `VarDumper::dump()` and the
`yiisoft/var-dumper` helpers `d()`, `dump()`, and `dd()` pass through it while the application output stays exactly
what the decorated handler produces. When `symfony/var-dumper` is loaded first, as Codeception and PsySH do, its own
global `dump()` and `dd()` are defined instead and never reach this proxy.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a dump-handler proxy that records and then forwards each dump. | `DumpHandlerProxy` |
| [`handle()`](#method-handle) | Records the dump with its call site, then forwards it to the decorated handler. | `DumpHandlerProxy` |
| [`handler()`](#method-handler) | Returns the handler the proxy decorates. | `DumpHandlerProxy` |

## Method details

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

```php
public function __construct(Yiisoft\VarDumper\HandlerInterface $handler, Yii3\Debug\Collector\DumpCollector $collector)
```

Creates a dump-handler proxy that records and then forwards each dump.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$handler` | `Yiisoft\VarDumper\HandlerInterface` | Handler that was the default before the proxy, receiving every dump. |
| `$collector` | [`Yii3\Debug\Collector\DumpCollector`](/docs/extensions/yii3-debug/reference/collector/dumpcollector/index.md) | Collector recording the dumps of the request. |

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

```php
public function handle(mixed $variable, int $depth, bool $highlight = false): void
```

Records the dump with its call site, then forwards it to the decorated handler.

Recording comes first, so the dump is already in the collector when the decorated handler throws, or when `dd()`
ends the script right after the output and [`DeferredCapture`](/docs/extensions/yii3-debug/reference/capture/deferredcapture/index.md) writes the capture
armed for the request at shutdown.

**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. |

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

```php
public function handler(): Yiisoft\VarDumper\HandlerInterface
```

Returns the handler the proxy decorates.

**Returns**

`Yiisoft\VarDumper\HandlerInterface`: Handler receiving every forwarded dump.