# CompareAction

> Compares two retained debugger snapshots.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Action](/docs/extensions/yii3-debug/reference/action/index.md) › CompareAction

| final readonly class | `Yii3\Debug\Action\CompareAction` |
| --- | --- |
| Implements | [`DebugActionInterface`](/docs/extensions/yii3-debug/reference/action/debugactioninterface/index.md) |
| Source | [`src/Action/CompareAction.php`](https://github.com/yii3/debug/blob/main/src/Action/CompareAction.php#L21) |

Compares two retained debugger snapshots.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates the comparison endpoint backed by retained snapshots and the shared page renderer. | `CompareAction` |
| [`__invoke()`](#method-__invoke) | Renders the comparison page for the two captures the query parameters select. | `CompareAction` |

## Method details

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

```php
public function __construct(PHPForge\Debug\Storage\SnapshotStore $store, Yii3\Debug\Web\DebugPageRenderer $renderer, Psr\Http\Message\ResponseFactoryInterface $responseFactory, Psr\Http\Message\StreamFactoryInterface $streamFactory)
```

Creates the comparison endpoint backed by retained snapshots and the shared page renderer.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$store` | `PHPForge\Debug\Storage\SnapshotStore` | Store the captured snapshots are read from. |
| `$renderer` | [`Yii3\Debug\Web\DebugPageRenderer`](/docs/extensions/yii3-debug/reference/web/debugpagerenderer/index.md) | Renderer producing the debugger page markup. |
| `$responseFactory` | `Psr\Http\Message\ResponseFactoryInterface` | Factory building the PSR-7 response. |
| `$streamFactory` | `Psr\Http\Message\StreamFactoryInterface` | Factory building the PSR-7 response body. |

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

```php
public function __invoke(Psr\Http\Message\ServerRequestInterface $request): Psr\Http\Message\ResponseInterface
```

Renders the comparison page for the two captures the query parameters select.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$request` | `Psr\Http\Message\ServerRequestInterface` | Incoming request carrying the query parameters. |

**Returns**

`Psr\Http\Message\ResponseInterface`: Rendered page, or a `404` response when the capture is missing.