Skip to content

Filesystem

github-actions edited this page Apr 17, 2026 · 1 revision

Concrete implementation of the standard filesystem interface.

This class wraps over the Symfony Filesystem component, automatically converting provided paths to absolute representations when a base path is supplied or dynamically inferred from the generic working directory.


Methods

exists

Checks whether a file or directory exists.

public exists(iterable<string>|string $files, string|null $basePath = null): bool

Parameters:

Parameter Type Description
$files iterable|string the file(s) or directory(ies) to check
$basePath string|null the base path used to resolve relative paths

Return Value:

true if the path exists, false otherwise


readFile

Reads the entire content of a file.

public readFile(string $filename, string|null $path = null): string

Parameters:

Parameter Type Description
$filename string the target filename to read
$path string|null the optional base path to resolve the filename against

Return Value:

the content of the file


dumpFile

Writes content to a file, overriding it if it already exists.

public dumpFile(string $filename, mixed $content, string|null $path = null): void

Parameters:

Parameter Type Description
$filename string the filename to write to
$content mixed the content to write
$path string|null the optional base path to resolve the filename against

copy

Copies a file to a target path.

public copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void

Parameters:

Parameter Type Description
$originFile string the source file path to copy
$targetFile string the target file path to create
$overwriteNewerFiles bool whether newer target files MAY be overwritten

chmod

Changes the permission mode for one or more files.

public chmod(iterable<string>|string $files, int $mode, int $umask = 00, bool $recursive = false): void

Parameters:

Parameter Type Description
$files iterable|string the target file paths
$mode int the permission mode to apply
$umask int the umask to apply
$recursive bool whether permissions SHOULD be applied recursively

getAbsolutePath

Resolves a path or iterable of paths into their absolute path representation.

public getAbsolutePath(iterable<string>|string $files, string|null $basePath = null): iterable<string>|string

Parameters:

Parameter Type Description
$files iterable|string the path(s) to resolve
$basePath string|null the base path for relative path resolution

Return Value:

the resolved absolute path(s)


mkdir

Creates a directory recursively.

public mkdir(iterable<string>|string $dirs, int $mode = 0777, string|null $basePath = null): void

Parameters:

Parameter Type Description
$dirs iterable|string the directory path(s) to create
$mode int the permissions mode (defaults to 0777)
$basePath string|null the base path for relative path resolution

makePathRelative

Computes the relative path from the base path to the target path.

public makePathRelative(string $path, string|null $basePath = null): string

Parameters:

Parameter Type Description
$path string the target absolute or relative path
$basePath string|null the origin point; defaults to the current working directory

Return Value:

the computed relative path


basename

Returns the trailing name component of a path.

public basename(string $path, string $suffix = ''): string

Parameters:

Parameter Type Description
$path string the path to process
$suffix string an optional suffix to strip from the returned basename

Return Value:

the base name of the given path


dirname

Returns a parent directory's path.

public dirname(string $path, int $levels = 1): string

Parameters:

Parameter Type Description
$path string the path to evaluate
$levels int the number of parent directories to go up

Return Value:

the parent path name


Clone this wiki locally