class Filesystem (View source)

Traits

Methods

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

Register a custom macro.

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 exists.

string
get(string $path)

Get the contents of a file.

mixed
getRequire(string $path)

Get the returned value of a file.

mixed
requireOnce(string $file)

Require the given file once.

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

Write the contents of a file.

int
prepend(string $path, string $data)

Prepend to a file.

int
append(string $path, string $data)

Append to a file.

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.

string
name(string $path)

Extract the file name 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
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)

Find path names matching a given pattern.

array
files(string $directory)

Get an array of all files in a directory.

array
allFiles(string $directory)

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 = 493, bool $recursive = false, bool $force = false)

Create a directory.

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

Copy a directory from one location to another.

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

Recursively delete a directory.

bool
cleanDirectory(string $directory)

Empty the specified directory of all files and folders.

Details

in Macroable at line line 22
static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

in Macroable at line line 33
static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line line 47
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line line 73
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line line 19
bool exists(string $path)

Determine if a file exists.

Parameters

string $path

Return Value

bool

at line line 32
string get(string $path)

Get the contents of a file.

Parameters

string $path

Return Value

string

Exceptions

FileNotFoundException

at line line 47
mixed getRequire(string $path)

Get the returned value of a file.

Parameters

string $path

Return Value

mixed

Exceptions

FileNotFoundException

at line line 60
mixed requireOnce(string $file)

Require the given file once.

Parameters

string $file

Return Value

mixed

at line line 73
int put(string $path, string $contents, bool $lock = false)

Write the contents of a file.

Parameters

string $path
string $contents
bool $lock

Return Value

int

at line line 85
int prepend(string $path, string $data)

Prepend to a file.

Parameters

string $path
string $data

Return Value

int

at line line 102
int append(string $path, string $data)

Append to a file.

Parameters

string $path
string $data

Return Value

int

at line line 113
bool delete(string|array $paths)

Delete the file at a given path.

Parameters

string|array $paths

Return Value

bool

at line line 144
bool move(string $path, string $target)

Move a file to a new location.

Parameters

string $path
string $target

Return Value

bool

at line line 156
bool copy(string $path, string $target)

Copy a file to a new location.

Parameters

string $path
string $target

Return Value

bool

at line line 167
string name(string $path)

Extract the file name from a file path.

Parameters

string $path

Return Value

string

at line line 178
string extension(string $path)

Extract the file extension from a file path.

Parameters

string $path

Return Value

string

at line line 189
string type(string $path)

Get the file type of a given file.

Parameters

string $path

Return Value

string

at line line 200
string|false mimeType(string $path)

Get the mime-type of a given file.

Parameters

string $path

Return Value

string|false

at line line 211
int size(string $path)

Get the file size of a given file.

Parameters

string $path

Return Value

int

at line line 222
int lastModified(string $path)

Get the file's last modification time.

Parameters

string $path

Return Value

int

at line line 233
bool isDirectory(string $directory)

Determine if the given path is a directory.

Parameters

string $directory

Return Value

bool

at line line 244
bool isWritable(string $path)

Determine if the given path is writable.

Parameters

string $path

Return Value

bool

at line line 255
bool isFile(string $file)

Determine if the given path is a file.

Parameters

string $file

Return Value

bool

at line line 267
array glob(string $pattern, int $flags)

Find path names matching a given pattern.

Parameters

string $pattern
int $flags

Return Value

array

at line line 278
array files(string $directory)

Get an array of all files in a directory.

Parameters

string $directory

Return Value

array

at line line 299
array allFiles(string $directory)

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

Parameters

string $directory

Return Value

array

at line line 310
array directories(string $directory)

Get all of the directories within a given directory.

Parameters

string $directory

Return Value

array

at line line 331
bool makeDirectory(string $path, int $mode = 493, bool $recursive = false, bool $force = false)

Create a directory.

Parameters

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

Return Value

bool

at line line 349
bool copyDirectory(string $directory, string $destination, int $options = null)

Copy a directory from one location to another.

Parameters

string $directory
string $destination
int $options

Return Value

bool

at line line 400
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

at line line 436
bool cleanDirectory(string $directory)

Empty the specified directory of all files and folders.

Parameters

string $directory

Return Value

bool