# SnapshotStore

> Yii2 compatibility facade for the framework-neutral snapshot store.

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › [storage](/docs/extensions/debug/reference/storage/index.md) › SnapshotStore

| final class | `yii\debug\storage\SnapshotStore` |
| --- | --- |
| Source | [`src/storage/SnapshotStore.php`](https://github.com/yii2-extensions/debug/blob/main/src/storage/SnapshotStore.php#L20) |

Yii2 compatibility facade for the framework-neutral snapshot store.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a Yii2 facade for the framework-neutral store. | `SnapshotStore` |
| [`forModule()`](#method-forModule) static | Creates a store bound to the module's data path and permission settings. | `SnapshotStore` |
| [`loadManifest()`](#method-loadManifest) | Returns manifest entries ordered from newest to oldest. | `SnapshotStore` |
| [`loadManifestResult()`](#method-loadManifestResult) | Returns manifest entries together with an optional core storage diagnostic. | `SnapshotStore` |
| [`readSnapshot()`](#method-readSnapshot) | Returns a stored snapshot or `null` when unavailable. | `SnapshotStore` |
| [`writeSnapshot()`](#method-writeSnapshot) | Writes a snapshot and manifest update through one core storage transaction. | `SnapshotStore` |
| [`writeSnapshotResult()`](#method-writeSnapshotResult) | Writes a snapshot and returns the committed manifest from the same storage transaction, without a second read. | `SnapshotStore` |

## Method details

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

```php
public function __construct(string $path, int $dirMode, int|null $fileMode)
```

Creates a Yii2 facade for the framework-neutral store.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$path` | `string` | Storage directory path. |
| `$dirMode` | `int` | Directory permissions used when creating the storage path. |
| `$fileMode` | `int\|null` | File permissions or `null` to preserve the system default. |

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

```php
public static function forModule(yii\debug\Module $module): self
```

Creates a store bound to the module's data path and permission settings.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$module` | [`yii\debug\Module`](/docs/extensions/debug/reference/module/index.md) | Debug module whose `dataPath`, `dirMode`, and `fileMode` configure the store. |

**Returns**

`self`: Store bound to the module settings.

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

```php
public function loadManifest(): array<string, PHPForge\Debug\Storage\RequestSummary>
```

Returns manifest entries ordered from newest to oldest.

**Returns**

`array<string, PHPForge\Debug\Storage\RequestSummary>`: Newest entries first.

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

```php
public function loadManifestResult(): PHPForge\Debug\Storage\ManifestReadResult
```

Returns manifest entries together with an optional core storage diagnostic.

**Returns**

`PHPForge\Debug\Storage\ManifestReadResult`: Manifest entries plus the storage diagnostic, when one was raised.

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

```php
public function readSnapshot(string $tag): PHPForge\Debug\Storage\DebugSnapshot|null
```

Returns a stored snapshot or `null` when unavailable.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$tag` | `string` | Snapshot tag. |

**Returns**

`PHPForge\Debug\Storage\DebugSnapshot|null`: Hydrated snapshot or `null` when unavailable.

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

```php
public function writeSnapshot(PHPForge\Debug\Storage\DebugSnapshot $snapshot, int $historySize): list<PHPForge\Debug\Storage\RequestSummary>
```

Writes a snapshot and manifest update through one core storage transaction.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$snapshot` | `PHPForge\Debug\Storage\DebugSnapshot` | Snapshot to persist. |
| `$historySize` | `int` | Maximum number of retained entries. |

**Returns**

`list<PHPForge\Debug\Storage\RequestSummary>`: Entries evicted from the manifest.

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

```php
public function writeSnapshotResult(PHPForge\Debug\Storage\DebugSnapshot $snapshot, int $historySize): yii\debug\storage\SnapshotWriteResult
```

Writes a snapshot and returns the committed manifest from the same storage transaction, without a second read.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$snapshot` | `PHPForge\Debug\Storage\DebugSnapshot` | Snapshot to persist. |
| `$historySize` | `int` | Maximum number of retained entries. |

**Returns**

[`SnapshotWriteResult`](/docs/extensions/debug/reference/storage/snapshotwriteresult/index.md): Committed entries and evictions.