Skip to content
PHP Ecosystem
Explore

SnapshotStore

API reference › Debug Core › Storage › SnapshotStore

final classPHPForge\Debug\Storage\SnapshotStore
Sourcesrc/Storage/SnapshotStore.php

Provides JSON filesystem storage, manifest locking, atomic writes, and snapshot garbage collection.

MethodDescriptionDefined by
__construct()Creates a filesystem store with directory and file permission modes.SnapshotStore
clear()Removes stored manifests, snapshots, and temporary files.SnapshotStore
loadManifest()Returns manifest entries ordered from newest to oldest.SnapshotStore
loadManifestResult()Returns manifest entries and preserves any read diagnostic for observable error handling.SnapshotStore
readSnapshot()Returns a stored snapshot or null when the tag or persisted payload is invalid.SnapshotStore
readSnapshotResult()Returns a stored snapshot and preserves any read diagnostic for observable error handling.SnapshotStore
writeSnapshot()Writes a snapshot, updates the manifest, and runs garbage collection under one exclusive lock.SnapshotStore
writeSnapshotResult()Writes a snapshot and returns the already-hydrated committed manifest together with evicted entries.SnapshotStore
public function __construct(string $path, int $dirMode, int|null $fileMode)

Creates a filesystem store with directory and file permission modes.

Parameters

ParameterTypeDescription
$pathstringStorage directory path.
$dirModeintDirectory permissions used when creating the storage path.
$fileModeint|nullFile permissions or null to preserve the system default.
public function clear(): void

Removes stored manifests, snapshots, and temporary files.

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

Returns manifest entries ordered from newest to oldest.

Returns

array<string, RequestSummary>: Newest entries first.

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

Returns manifest entries and preserves any read diagnostic for observable error handling.

Returns

ManifestReadResult: Newest entries first plus an optional storage failure.

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

Returns a stored snapshot or null when the tag or persisted payload is invalid.

Parameters

ParameterTypeDescription
$tagstringSnapshot tag.

Returns

DebugSnapshot|null: Hydrated snapshot or null when the stored value is unavailable or invalid.

public function readSnapshotResult(string $tag): PHPForge\Debug\Storage\SnapshotReadResult

Returns a stored snapshot and preserves any read diagnostic for observable error handling.

Parameters

ParameterTypeDescription
$tagstringSnapshot tag.

Returns

SnapshotReadResult: Snapshot, missing state, or storage failure.

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

Writes a snapshot, updates the manifest, and runs garbage collection under one exclusive lock.

Parameters

ParameterTypeDescription
$snapshotDebugSnapshotSnapshot to persist.
$historySizeintMaximum number of retained entries.

Returns

list<RequestSummary>: Entries evicted from the manifest.

public function writeSnapshotResult(PHPForge\Debug\Storage\DebugSnapshot $snapshot, int $historySize): PHPForge\Debug\Storage\SnapshotWriteResult

Writes a snapshot and returns the already-hydrated committed manifest together with evicted entries.

Adapters that need the resulting manifest can consume this result without acquiring the lock and decoding the index a second time.

Parameters

ParameterTypeDescription
$snapshotDebugSnapshotSnapshot to persist.
$historySizeintMaximum number of retained entries.

Returns

SnapshotWriteResult: Committed manifest and entries evicted from it.