Skip to content

FilesystemManager

App-facing entry point: $container->get(FilesystemManager::class)->write('reports/x.csv', $csv).

Resolves the configured driver (or an explicit alias) from FilesystemDriverRegistry via Container::get() — a driver is a long-lived service (memoized like any other), not constructed per call. Mirrors QueueManager exactly.

final readonly class FilesystemManager

SourceFilesystemManager.php

public function __construct(Container $container, FilesystemConfig $config): mixed

ParameterTypeDescription
$containerContainer
$configFilesystemConfig

Returns mixed

MethodDescription
delete(string $path): voidDeletes $path from the default disk.
disk(?string $alias = null): FilesystemAdapterInterfaceResolves a disk by driver alias, defaulting to the configured filesystem.default_disk.
exists(string $path): boolReports whether $path exists on the default disk.
listContents(string $path = ''): list<string>
listableDisk(?string $alias = null): ListableFilesystemInterfaceThe configured disk, narrowed to one that can enumerate its contents.
read(string $path): stringReads $path from the default disk.
write(string $path, string $contents): voidWrites $contents to $path on the default disk.

public function delete(string $path): void

Deletes $path from the default disk.

ParameterTypeDescription
$pathstring

public function disk(?string $alias = null): FilesystemAdapterInterface

Resolves a disk by driver alias, defaulting to the configured filesystem.default_disk.

The alias is mapped to a class through FilesystemDriverRegistry and the instance comes from the container, so a driver registered as a singleton is shared across calls rather than rebuilt per operation.

ParameterTypeDescription
$alias?``string

Returns FilesystemAdapterInterface

ThrowsWhen
RuntimeExceptionIf the alias is unknown, or the class the container returned does not implement FilesystemAdapterInterface.

public function exists(string $path): bool

Reports whether $path exists on the default disk.

ParameterTypeDescription
$pathstring

Returns bool

public function listContents(string $path = ''): list<string>

ParameterTypeDescription
$pathstring

Returns list``<``string``> — Relative paths directly under $path, non-recursive.

ThrowsWhen
RuntimeExceptionIf the configured driver cannot enumerate.

public function listableDisk(?string $alias = null): ListableFilesystemInterface

The configured disk, narrowed to one that can enumerate its contents.

Not every store can: the object-store drivers are built on single-object calls with no list endpoint. Asking here rather than discovering it from a thrown exception means the failure names the disk that cannot do it and the driver behind it.

ParameterTypeDescription
$alias?``string

Returns ListableFilesystemInterface

ThrowsWhen
RuntimeExceptionIf the resolved driver is not listable.

public function read(string $path): string

Reads $path from the default disk.

ParameterTypeDescription
$pathstring

Returns string

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

Writes $contents to $path on the default disk.

ParameterTypeDescription
$pathstring
$contentsstring