Filesystem
    
            
            in package
            
        
    
    
    
Provides basic utility to manipulate the file system.
Tags
Table of Contents
Methods
- appendToFile() : void
 - Appends content to an existing file.
 - chgrp() : void
 - Change the group of an array of files or directories.
 - chmod() : void
 - Change mode for an array of files or directories.
 - chown() : void
 - Change the owner of an array of files or directories.
 - copy() : void
 - Copies a file.
 - dumpFile() : void
 - Atomically dumps content into a file.
 - exists() : bool
 - Checks the existence of files or directories.
 - hardlink() : void
 - Creates a hard link, or several hard links to a file.
 - isAbsolutePath() : bool
 - Returns whether the file path is an absolute path.
 - makePathRelative() : string
 - Given an existing path, convert it to a path relative to a given starting path.
 - mirror() : void
 - Mirrors a directory to another.
 - mkdir() : void
 - Creates a directory recursively.
 - readFile() : string
 - Returns the content of a file as a string.
 - readlink() : string|null
 - Resolves links in paths.
 - remove() : void
 - Removes files or directories.
 - rename() : void
 - Renames a file or a directory.
 - symlink() : void
 - Creates a symbolic link or copy a directory.
 - tempnam() : string
 - Creates a temporary file with support for custom stream wrappers.
 - touch() : void
 - Sets access and modification time of file.
 
Methods
appendToFile()
Appends content to an existing file.
    public
                    appendToFile(string $filename, string|resource $content[, bool $lock = false ]) : void
    Parameters
- $filename : string
 - $content : string|resource
 - 
                    
The content to append
 - $lock : bool = false
 - 
                    
Whether the file should be locked when writing to it
 
Tags
chgrp()
Change the group of an array of files or directories.
    public
                    chgrp(string|iterable<string|int, mixed> $files, string|int $group[, bool $recursive = false ]) : void
    This method always throws on Windows, as the underlying PHP function is not supported.
Parameters
- $files : string|iterable<string|int, mixed>
 - $group : string|int
 - 
                    
A group name or number
 - $recursive : bool = false
 - 
                    
Whether change the group recursively or not
 
Tags
chmod()
Change mode for an array of files or directories.
    public
                    chmod(string|iterable<string|int, mixed> $files, int $mode[, int $umask = 00 ][, bool $recursive = false ]) : void
    Parameters
- $files : string|iterable<string|int, mixed>
 - $mode : int
 - 
                    
The new mode (octal)
 - $umask : int = 00
 - 
                    
The mode mask (octal)
 - $recursive : bool = false
 - 
                    
Whether change the mod recursively or not
 
Tags
chown()
Change the owner of an array of files or directories.
    public
                    chown(string|iterable<string|int, mixed> $files, string|int $user[, bool $recursive = false ]) : void
    This method always throws on Windows, as the underlying PHP function is not supported.
Parameters
- $files : string|iterable<string|int, mixed>
 - $user : string|int
 - 
                    
A user name or number
 - $recursive : bool = false
 - 
                    
Whether change the owner recursively or not
 
Tags
copy()
Copies a file.
    public
                    copy(string $originFile, string $targetFile[, bool $overwriteNewerFiles = false ]) : void
    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.
Parameters
- $originFile : string
 - $targetFile : string
 - $overwriteNewerFiles : bool = false
 
Tags
dumpFile()
Atomically dumps content into a file.
    public
                    dumpFile(string $filename, string|resource $content) : void
    Parameters
- $filename : string
 - $content : string|resource
 - 
                    
The data to write into the file
 
Tags
exists()
Checks the existence of files or directories.
    public
                    exists(string|iterable<string|int, mixed> $files) : bool
    Parameters
- $files : string|iterable<string|int, mixed>
 
Return values
boolhardlink()
Creates a hard link, or several hard links to a file.
    public
                    hardlink(string $originFile, string|array<string|int, string> $targetFiles) : void
    Parameters
- $originFile : string
 - $targetFiles : string|array<string|int, string>
 - 
                    
The target file(s)
 
Tags
isAbsolutePath()
Returns whether the file path is an absolute path.
    public
                    isAbsolutePath(string $file) : bool
    Parameters
- $file : string
 
Return values
boolmakePathRelative()
Given an existing path, convert it to a path relative to a given starting path.
    public
                    makePathRelative(string $endPath, string $startPath) : string
    Parameters
- $endPath : string
 - $startPath : string
 
Return values
stringmirror()
Mirrors a directory to another.
    public
                    mirror(string $originDir, string $targetDir[, Traversable|null $iterator = null ][, array<string|int, mixed> $options = [] ]) : void
    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 
overrideoption) - files in the target directory that do not exist in the source directory will not be deleted (see the 
deleteoption) 
Parameters
- $originDir : string
 - $targetDir : string
 - $iterator : Traversable|null = null
 - 
                    
Iterator that filters which files and directories to copy, if null a recursive iterator is created
 - $options : array<string|int, mixed> = []
 - 
                    
An array of boolean options Valid options are:
- $options['override'] If true, target files newer than origin files are overwritten (see copy(), defaults to false)
 - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false)
 - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
 
 
Tags
mkdir()
Creates a directory recursively.
    public
                    mkdir(string|iterable<string|int, mixed> $dirs[, int $mode = 0777 ]) : void
    Parameters
- $dirs : string|iterable<string|int, mixed>
 - $mode : int = 0777
 
Tags
readFile()
Returns the content of a file as a string.
    public
                    readFile(string $filename) : string
    Parameters
- $filename : string
 
Tags
Return values
stringreadlink()
Resolves links in paths.
    public
                    readlink(string $path[, bool $canonicalize = false ]) : string|null
    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
Parameters
- $path : string
 - $canonicalize : bool = false
 
Return values
string|nullremove()
Removes files or directories.
    public
                    remove(string|iterable<string|int, mixed> $files) : void
    Parameters
- $files : string|iterable<string|int, mixed>
 
Tags
rename()
Renames a file or a directory.
    public
                    rename(string $origin, string $target[, bool $overwrite = false ]) : void
    Parameters
- $origin : string
 - $target : string
 - $overwrite : bool = false
 
Tags
symlink()
Creates a symbolic link or copy a directory.
    public
                    symlink(string $originDir, string $targetDir[, bool $copyOnWindows = false ]) : void
    Parameters
- $originDir : string
 - $targetDir : string
 - $copyOnWindows : bool = false
 
Tags
tempnam()
Creates a temporary file with support for custom stream wrappers.
    public
                    tempnam(string $dir, string $prefix[, string $suffix = '' ]) : string
    Parameters
- $dir : string
 - $prefix : string
 - 
                    
The prefix of the generated temporary filename Note: Windows uses only the first three characters of prefix
 - $suffix : string = ''
 - 
                    
The suffix of the generated temporary filename
 
Return values
string —The new temporary filename (with path), or throw an exception on failure
touch()
Sets access and modification time of file.
    public
                    touch(string|iterable<string|int, mixed> $files[, int|null $time = null ][, int|null $atime = null ]) : void
    Parameters
- $files : string|iterable<string|int, mixed>
 - $time : int|null = null
 - 
                    
The touch time as a Unix timestamp, if not supplied the current system time is used
 - $atime : int|null = null
 - 
                    
The access time as a Unix timestamp, if not supplied the current system time is used