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.
Synopsis
Section titled “Synopsis”final readonly class FilesystemManager
| Source | FilesystemManager.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(Container $container, FilesystemConfig $config): mixed
| Parameter | Type | Description |
|---|---|---|
$container | Container | |
$config | FilesystemConfig |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
delete(string $path): void | Deletes $path from the default disk. |
disk(?string $alias = null): FilesystemAdapterInterface | Resolves a disk by driver alias, defaulting to the configured filesystem.default_disk. |
exists(string $path): bool | Reports whether $path exists on the default disk. |
listContents(string $path = ''): list<string> | |
listableDisk(?string $alias = null): ListableFilesystemInterface | The configured disk, narrowed to one that can enumerate its contents. |
read(string $path): string | Reads $path from the default disk. |
write(string $path, string $contents): void | Writes $contents to $path on the default disk. |
delete()
Section titled “delete()”public function delete(string $path): void
Deletes $path from the default disk.
| Parameter | Type | Description |
|---|---|---|
$path | string |
disk()
Section titled “disk()”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.
| Parameter | Type | Description |
|---|---|---|
$alias | ?``string |
Returns FilesystemAdapterInterface
| Throws | When |
|---|---|
RuntimeException | If the alias is unknown, or the class the container returned does not implement FilesystemAdapterInterface. |
exists()
Section titled “exists()”public function exists(string $path): bool
Reports whether $path exists on the default disk.
| Parameter | Type | Description |
|---|---|---|
$path | string |
Returns bool
listContents()
Section titled “listContents()”public function listContents(string $path = ''): list<string>
| Parameter | Type | Description |
|---|---|---|
$path | string |
Returns list``<``string``> — Relative paths directly under $path, non-recursive.
| Throws | When |
|---|---|
RuntimeException | If the configured driver cannot enumerate. |
listableDisk()
Section titled “listableDisk()”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.
| Parameter | Type | Description |
|---|---|---|
$alias | ?``string |
Returns ListableFilesystemInterface
| Throws | When |
|---|---|
RuntimeException | If the resolved driver is not listable. |
read()
Section titled “read()”public function read(string $path): string
Reads $path from the default disk.
| Parameter | Type | Description |
|---|---|---|
$path | string |
Returns string
write()
Section titled “write()”public function write(string $path, string $contents): void
Writes $contents to $path on the default disk.
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$contents | string |