Skip to content

FilesystemAdapterInterface

A general-purpose “read/write/list a file” contract, distinct from SessionPersistenceInterface (session-shaped) and the legacy Storage hierarchy (SessionHandlerInterface- bound).

Implementations are registered by alias in FilesystemDriverRegistry and resolved through FilesystemManager.

Deliberately out of scope for v1: visibility/ACLs, mime-type detection, streaming read/write, directory-as-first-class-object semantics beyond what a driver needs internally, copy/move, checksums/ETags.

Enumeration is not here: a store built on single-object calls cannot offer it, so it lives on ListableFilesystemInterface and a driver opts in by implementing that instead. FilesystemAdapterInterface::size() and FilesystemAdapterInterface::lastModified() are supported by every shipped driver, though a cloud provider that omits the corresponding response header makes them fail at runtime.

interface FilesystemAdapterInterface

Implemented byListableFilesystemInterface, ObjectStoreFilesystemAdapter
SourceFilesystemAdapterInterface.php
MethodDescription
delete(string $path): voidBest-effort: a no-op if $path does not exist.
exists(string $path): boolReports whether a file is stored at $path.
lastModified(string $path): DateTimeImmutable
read(string $path): string
size(string $path): int
write(string $path, string $contents): voidStores $contents at $path, replacing whatever was there.

abstract public function delete(string $path): void

Best-effort: a no-op if $path does not exist.

ParameterTypeDescription
$pathstring

abstract public function exists(string $path): bool

Reports whether a file is stored at $path.

Directories and prefixes do not count as files.

ParameterTypeDescription
$pathstring

Returns bool

abstract public function lastModified(string $path): DateTimeImmutable

ParameterTypeDescription
$pathstring

Returns DateTimeImmutable

ThrowsWhen
FileNotFoundStorageExceptionif $path does not exist.

abstract public function read(string $path): string

ParameterTypeDescription
$pathstring

Returns string

ThrowsWhen
FileNotFoundStorageExceptionif $path does not exist.

abstract public function size(string $path): int

ParameterTypeDescription
$pathstring

Returns int

ThrowsWhen
FileNotFoundStorageExceptionif $path does not exist.

abstract public function write(string $path, string $contents): void

Stores $contents at $path, replacing whatever was there.

Implementations create whatever container the path implies (a parent directory, a key prefix) rather than requiring the caller to prepare it, and a reader must never observe a half-written file.

ParameterTypeDescription
$pathstring
$contentsstring