Filesystem
class Filesystem
Provides basic utility to manipulate the file system.
Methods
Copies a file.
Creates a directory recursively.
Checks the existence of files or directories.
Sets access and modification time of file.
Removes files or directories.
Change mode for an array of files or directories.
Change the owner of an array of files or directories.
Change the group of an array of files or directories.
Renames a file or a directory.
Creates a symbolic link or copy a directory.
Creates a hard link, or several hard links to a file.
Resolves links in paths.
Given an existing path, convert it to a path relative to a given starting path.
Mirrors a directory to another.
Returns whether the file path is an absolute path.
Creates a temporary file with support for custom stream wrappers.
Atomically dumps content into a file.
Appends content to an existing file.
No description
Details
copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false)
Copies a file.
If the target file is older than the origin file, it's always overwritten. If the target file is newer, it is overwritten only when the $overwriteNewerFiles option is set to true.
touch(string|iterable $files, int $time = null, int $atime = null)
Sets access and modification time of file.
chmod(string|iterable $files, int $mode, int $umask = 00, bool $recursive = false)
Change mode for an array of files or directories.
chown(string|iterable $files, string $user, bool $recursive = false)
Change the owner of an array of files or directories.
chgrp(string|iterable $files, string $group, bool $recursive = false)
Change the group of an array of files or directories.
symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
Creates a symbolic link or copy a directory.
hardlink(string $originFile, string|string[] $targetFiles)
Creates a hard link, or several hard links to a file.
string|null
readlink(string $path, bool $canonicalize = false)
Resolves links in paths.
With $canonicalize = false (default) - if $path does not exist or is not a link, returns null - if $path is a link, returns the next direct target of the link without considering the existence of the target
With $canonicalize = true - if $path does not exist, returns null - if $path exists, returns its absolute fully resolved final version
string
makePathRelative(string $endPath, string $startPath)
Given an existing path, convert it to a path relative to a given starting path.
mirror(string $originDir, string $targetDir, Traversable $iterator = null, array $options = array())
Mirrors a directory to another.
Copies files and directories from the origin directory into the target directory. By default:
- existing files in the target directory will be overwritten, except if they are newer (see the
override
option) - files in the target directory that do not exist in the source directory will not be deleted (see the
delete
option)