Filesystem
final class Filesystem (View source)
Exposes the framework's filesystem collaborators through one facade while retaining their typed failure contracts.
Methods
Composes the filesystem contracts exposed through this immutable facade.
Returns the collaborator responsible for filesystem mutations and traversal.
Returns the collaborator responsible for file reads and metadata.
Returns the collaborator responsible for callback lock lifecycles.
Creates a directory and any missing parents.
Deletes a file, link, or directory tree without following linked directories.
Copies a regular file or directory without following symbolic links.
Atomically publishes file contents from a same-directory temporary file.
Atomically renames a file within one local filesystem.
Lazily yields direct entries or a complete tree without following linked directories.
Lazily yields direct glob matches constrained to the selected directory.
Lazily yields entry metadata without following linked directories.
Reads the complete contents of a regular file.
Returns the size of a regular file in bytes.
Returns the modification time of an existing filesystem path.
Hashes a regular file with an explicitly supported algorithm.
Detects the MIME type of a regular file.
Returns the permission bits of an existing filesystem path.
Executes a callback while holding an exclusive lock.
Details
__construct
__construct(DirectoryManagerInterface $directoryManager, FileManagerInterface $fileManager, LockManagerInterface $lockManager)
Composes the filesystem contracts exposed through this immutable facade.
getDirectoryManager
DirectoryManagerInterface
getDirectoryManager()
Returns the collaborator responsible for filesystem mutations and traversal.
getFileManager
FileManagerInterface
getFileManager()
Returns the collaborator responsible for file reads and metadata.
getLockManager
LockManagerInterface
getLockManager()
Returns the collaborator responsible for callback lock lifecycles.
create
void
create(string $path, int $mode = 0775)
Creates a directory and any missing parents.
delete
void
delete(string $path)
Deletes a file, link, or directory tree without following linked directories.
copy
void
copy(string $src, string $dst, bool $overwrite = false)
Copies a regular file or directory without following symbolic links.
write
void
write(string $file, string $data, int|null $mode = 0666)
Atomically publishes file contents from a same-directory temporary file.
move
void
move(string $source, string $target)
Atomically renames a file within one local filesystem.
stream
Generator
stream(string $path, bool $recursive = true)
Lazily yields direct entries or a complete tree without following linked directories.
find
Generator
find(string $pattern, string $path)
Lazily yields direct glob matches constrained to the selected directory.
tree
Generator
tree(string $path, bool $recursive = true)
Lazily yields entry metadata without following linked directories.
read
string
read(string $file)
Reads the complete contents of a regular file.
size
int
size(string $file)
Returns the size of a regular file in bytes.
modified
int
modified(string $file)
Returns the modification time of an existing filesystem path.
hash
string
hash(string $file, string $algo = 'sha256')
Hashes a regular file with an explicitly supported algorithm.
mime
string
mime(string $file)
Detects the MIME type of a regular file.
permissions
int
permissions(string $file)
Returns the permission bits of an existing filesystem path.
lock
mixed
lock(string $file, callable $callback)
Executes a callback while holding an exclusive lock.