W3cubDocs

/Laravel 5.8

Filesystem

class Filesystem (View source)

Traits

Macroable

Properties

static protected array $macros The registered string macros. from Macroable

Methods

static void macro(string $name, object|callable $macro)

Register a custom macro.

from Macroable
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

from Macroable
static bool hasMacro(string $name)

Checks if macro is registered.

from Macroable
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
bool exists(string $path)

Determine if a file or directory exists.

string get(string $path, bool $lock = false)

Get the contents of a file.

string sharedGet(string $path)

Get contents of a file with shared access.

mixed getRequire(string $path)

Get the returned value of a file.

mixed requireOnce(string $file)

Require the given file once.

string hash(string $path)

Get the MD5 hash of the file at the given path.

int|bool put(string $path, string $contents, bool $lock = false)

Write the contents of a file.

void replace(string $path, string $content)

Write the contents of a file, replacing it atomically if it already exists.

int prepend(string $path, string $data)

Prepend to a file.

int append(string $path, string $data)

Append to a file.

mixed chmod(string $path, int|null $mode = null)

Get or set UNIX mode of a file or directory.

bool delete(string|array $paths)

Delete the file at a given path.

bool move(string $path, string $target)

Move a file to a new location.

bool copy(string $path, string $target)

Copy a file to a new location.

void link(string $target, string $link)

Create a hard link to the target file or directory.

string name(string $path)

Extract the file name from a file path.

string basename(string $path)

Extract the trailing name component from a file path.

string dirname(string $path)

Extract the parent directory from a file path.

string extension(string $path)

Extract the file extension from a file path.

string type(string $path)

Get the file type of a given file.

string|false mimeType(string $path)

Get the mime-type of a given file.

int size(string $path)

Get the file size of a given file.

int lastModified(string $path)

Get the file's last modification time.

bool isDirectory(string $directory)

Determine if the given path is a directory.

bool isReadable(string $path)

Determine if the given path is readable.

bool isWritable(string $path)

Determine if the given path is writable.

bool isFile(string $file)

Determine if the given path is a file.

array glob(string $pattern, int $flags = 0)

Find path names matching a given pattern.

SplFileInfo[] files(string $directory, bool $hidden = false)

Get an array of all files in a directory.

SplFileInfo[] allFiles(string $directory, bool $hidden = false)

Get all of the files from the given directory (recursive).

array directories(string $directory)

Get all of the directories within a given directory.

bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false)

Create a directory.

bool moveDirectory(string $from, string $to, bool $overwrite = false)

Move a directory.

bool copyDirectory(string $directory, string $destination, int|null $options = null)

Copy a directory from one location to another.

bool deleteDirectory(string $directory, bool $preserve = false)

Recursively delete a directory.

bool deleteDirectories(string $directory)

Remove all of the directories within a given directory.

bool cleanDirectory(string $directory)

Empty the specified directory of all files and folders.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

bool exists(string $path)

Determine if a file or directory exists.

Parameters

string $path

Return Value

bool

string get(string $path, bool $lock = false)

Get the contents of a file.

Parameters

string $path
bool $lock

Return Value

string

Exceptions

FileNotFoundException

string sharedGet(string $path)

Get contents of a file with shared access.

Parameters

string $path

Return Value

string

mixed getRequire(string $path)

Get the returned value of a file.

Parameters

string $path

Return Value

mixed

Exceptions

FileNotFoundException

mixed requireOnce(string $file)

Require the given file once.

Parameters

string $file

Return Value

mixed

string hash(string $path)

Get the MD5 hash of the file at the given path.

Parameters

string $path

Return Value

string

int|bool put(string $path, string $contents, bool $lock = false)

Write the contents of a file.

Parameters

string $path
string $contents
bool $lock

Return Value

int|bool

void replace(string $path, string $content)

Write the contents of a file, replacing it atomically if it already exists.

Parameters

string $path
string $content

Return Value

void

int prepend(string $path, string $data)

Prepend to a file.

Parameters

string $path
string $data

Return Value

int

int append(string $path, string $data)

Append to a file.

Parameters

string $path
string $data

Return Value

int

mixed chmod(string $path, int|null $mode = null)

Get or set UNIX mode of a file or directory.

Parameters

string $path
int|null $mode

Return Value

mixed

bool delete(string|array $paths)

Delete the file at a given path.

Parameters

string|array $paths

Return Value

bool

bool move(string $path, string $target)

Move a file to a new location.

Parameters

string $path
string $target

Return Value

bool

bool copy(string $path, string $target)

Copy a file to a new location.

Parameters

string $path
string $target

Return Value

bool

Create a hard link to the target file or directory.

Parameters

string $target
string $link

Return Value

void

string name(string $path)

Extract the file name from a file path.

Parameters

string $path

Return Value

string

string basename(string $path)

Extract the trailing name component from a file path.

Parameters

string $path

Return Value

string

string dirname(string $path)

Extract the parent directory from a file path.

Parameters

string $path

Return Value

string

string extension(string $path)

Extract the file extension from a file path.

Parameters

string $path

Return Value

string

string type(string $path)

Get the file type of a given file.

Parameters

string $path

Return Value

string

string|false mimeType(string $path)

Get the mime-type of a given file.

Parameters

string $path

Return Value

string|false

int size(string $path)

Get the file size of a given file.

Parameters

string $path

Return Value

int

int lastModified(string $path)

Get the file's last modification time.

Parameters

string $path

Return Value

int

bool isDirectory(string $directory)

Determine if the given path is a directory.

Parameters

string $directory

Return Value

bool

bool isReadable(string $path)

Determine if the given path is readable.

Parameters

string $path

Return Value

bool

bool isWritable(string $path)

Determine if the given path is writable.

Parameters

string $path

Return Value

bool

bool isFile(string $file)

Determine if the given path is a file.

Parameters

string $file

Return Value

bool

array glob(string $pattern, int $flags = 0)

Find path names matching a given pattern.

Parameters

string $pattern
int $flags

Return Value

array

SplFileInfo[] files(string $directory, bool $hidden = false)

Get an array of all files in a directory.

Parameters

string $directory
bool $hidden

Return Value

SplFileInfo[]

SplFileInfo[] allFiles(string $directory, bool $hidden = false)

Get all of the files from the given directory (recursive).

Parameters

string $directory
bool $hidden

Return Value

SplFileInfo[]

array directories(string $directory)

Get all of the directories within a given directory.

Parameters

string $directory

Return Value

array

bool makeDirectory(string $path, int $mode = 0755, bool $recursive = false, bool $force = false)

Create a directory.

Parameters

string $path
int $mode
bool $recursive
bool $force

Return Value

bool

bool moveDirectory(string $from, string $to, bool $overwrite = false)

Move a directory.

Parameters

string $from
string $to
bool $overwrite

Return Value

bool

bool copyDirectory(string $directory, string $destination, int|null $options = null)

Copy a directory from one location to another.

Parameters

string $directory
string $destination
int|null $options

Return Value

bool

bool deleteDirectory(string $directory, bool $preserve = false)

Recursively delete a directory.

The directory itself may be optionally preserved.

Parameters

string $directory
bool $preserve

Return Value

bool

bool deleteDirectories(string $directory)

Remove all of the directories within a given directory.

Parameters

string $directory

Return Value

bool

bool cleanDirectory(string $directory)

Empty the specified directory of all files and folders.

Parameters

string $directory

Return Value

bool

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.8/Illuminate/Filesystem/Filesystem.html