Class

Symfony\Component\HttpKernel\Util\Filesystem

class Filesystem

Provides basic utility to manipulate the file system.

Methods

copy(string $originFile, string $targetFile, array $override = false)

Copies a file.

Boolean mkdir(string|array|Traversable $dirs, int $mode = 511)

Creates a directory recursively.

touch(string|array|Traversable $files)

Creates empty files.

remove(string|array|Traversable $files)

Removes files or directories.

chmod(string|array|Traversable $files, integer $mode, integer $umask)

Change mode for an array of files or directories.

rename(string $origin, string $target)

Renames a file.

symlink(string $originDir, string $targetDir, Boolean $copyOnWindows = false)

Creates a symbolic link or copy a directory.

mirror(string $originDir, string $targetDir, Traversable $iterator = null, array $options = array())

Mirrors a directory to another.

Boolean isAbsolutePath(string $file)

Returns whether the file path is an absolute path.

Details

at line 32
public copy(string $originFile, string $targetFile, array $override = false)

Copies a file.

This method only copies the file if the origin file is newer than the target file.

By default, if the target already exists, it is not overridden.

Parameters

string $originFile The original filename
string $targetFile The target filename
array $override Whether to override an existing file or not

at line 55
public Boolean mkdir(string|array|Traversable $dirs, int $mode = 511)

Creates a directory recursively.

Parameters

string|array|Traversable $dirs The directory path
int $mode The directory mode

Return Value

Boolean true if the directory has been created, false otherwise

at line 74
public touch(string|array|Traversable $files)

Creates empty files.

Parameters

string|array|Traversable $files A filename, an array of files, or a \Traversable instance to remove

at line 86
public remove(string|array|Traversable $files)

Removes files or directories.

Parameters

string|array|Traversable $files A filename, an array of files, or a \Traversable instance to remove

at line 112
public chmod(string|array|Traversable $files, integer $mode, integer $umask)

Change mode for an array of files or directories.

Parameters

string|array|Traversable $files A filename, an array of files, or a \Traversable instance to remove
integer $mode The new mode
integer $umask The mode mask (octal)

at line 132
public rename(string $origin, string $target)

Renames a file.

Parameters

string $origin The origin filename
string $target The new filename

Exceptions

RuntimeException When target file already exists

Creates a symbolic link or copy a directory.

Parameters

string $originDir The origin directory path
string $targetDir The symbolic link name
Boolean $copyOnWindows Whether to copy files if on Windows

at line 184
public mirror(string $originDir, string $targetDir, Traversable $iterator = null, array $options = array())

Mirrors a directory to another.

Parameters

string $originDir The origin directory
string $targetDir The target directory
Traversable $iterator A Traversable instance
array $options An array of boolean options Valid options are: - $options['override'] Whether to override an existing file on copy or not (see copy()) - $options['copyonwindows'] Whether to copy files instead of links on Windows (see symlink())

Exceptions

RuntimeException When file type is unknown

at line 226
public Boolean isAbsolutePath(string $file)

Returns whether the file path is an absolute path.

Parameters

string $file A file path

Return Value

Boolean