interface Filesystem (View source)

Constants

VISIBILITY_PUBLIC

The public visibility setting.

VISIBILITY_PRIVATE

The private visibility setting.

Methods

string
path(string $path)

Get the full path to the file that exists at the given relative path.

bool
exists(string $path)

Determine if a file exists.

string|null
get(string $path)

Get the contents of a file.

resource|null
readStream(string $path)

Get a resource to read the file.

bool
put(string $path, StreamInterface|File|UploadedFile|string|resource $contents, mixed $options = [])

Write the contents of a file.

string|false
putFile(File|UploadedFile|string $path, File|UploadedFile|string|array|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

string|false
putFileAs(File|UploadedFile|string $path, File|UploadedFile|string|array|null $file, string|array|null $name = null, mixed $options = [])

Store the uploaded file on the disk with a given name.

bool
writeStream(string $path, resource $resource, array $options = [])

Write a new file using a stream.

string
getVisibility(string $path)

Get the visibility for the given path.

bool
setVisibility(string $path, string $visibility)

Set the visibility for the given path.

bool
prepend(string $path, string $data)

Prepend to a file.

bool
append(string $path, string $data)

Append to a file.

bool
delete(string|array $paths)

Delete the file at a given path.

bool
copy(string $from, string $to)

Copy a file to a new location.

bool
move(string $from, string $to)

Move a file to a new location.

int
size(string $path)

Get the file size of a given file.

int
lastModified(string $path)

Get the file's last modification time.

array
files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

array
allFiles(string|null $directory = null)

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

array
directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

array
allDirectories(string|null $directory = null)

Get all (recursive) of the directories within a given directory.

bool
makeDirectory(string $path)

Create a directory.

bool
deleteDirectory(string $directory)

Recursively delete a directory.

Details

string path(string $path)

Get the full path to the file that exists at the given relative path.

Parameters

string $path

Return Value

string

bool exists(string $path)

Determine if a file exists.

Parameters

string $path

Return Value

bool

string|null get(string $path)

Get the contents of a file.

Parameters

string $path

Return Value

string|null

resource|null readStream(string $path)

Get a resource to read the file.

Parameters

string $path

Return Value

resource|null

The path resource or null on failure.

bool put(string $path, StreamInterface|File|UploadedFile|string|resource $contents, mixed $options = [])

Write the contents of a file.

Parameters

string $path
StreamInterface|File|UploadedFile|string|resource $contents
mixed $options

Return Value

bool

string|false putFile(File|UploadedFile|string $path, File|UploadedFile|string|array|null $file = null, mixed $options = [])

Store the uploaded file on the disk.

Parameters

File|UploadedFile|string $path
File|UploadedFile|string|array|null $file
mixed $options

Return Value

string|false

string|false putFileAs(File|UploadedFile|string $path, File|UploadedFile|string|array|null $file, string|array|null $name = null, mixed $options = [])

Store the uploaded file on the disk with a given name.

Parameters

File|UploadedFile|string $path
File|UploadedFile|string|array|null $file
string|array|null $name
mixed $options

Return Value

string|false

bool writeStream(string $path, resource $resource, array $options = [])

Write a new file using a stream.

Parameters

string $path
resource $resource
array $options

Return Value

bool

string getVisibility(string $path)

Get the visibility for the given path.

Parameters

string $path

Return Value

string

bool setVisibility(string $path, string $visibility)

Set the visibility for the given path.

Parameters

string $path
string $visibility

Return Value

bool

bool prepend(string $path, string $data)

Prepend to a file.

Parameters

string $path
string $data

Return Value

bool

bool append(string $path, string $data)

Append to a file.

Parameters

string $path
string $data

Return Value

bool

bool delete(string|array $paths)

Delete the file at a given path.

Parameters

string|array $paths

Return Value

bool

bool copy(string $from, string $to)

Copy a file to a new location.

Parameters

string $from
string $to

Return Value

bool

bool move(string $from, string $to)

Move a file to a new location.

Parameters

string $from
string $to

Return Value

bool

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

array files(string|null $directory = null, bool $recursive = false)

Get an array of all files in a directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

array allFiles(string|null $directory = null)

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

Parameters

string|null $directory

Return Value

array

array directories(string|null $directory = null, bool $recursive = false)

Get all of the directories within a given directory.

Parameters

string|null $directory
bool $recursive

Return Value

array

array allDirectories(string|null $directory = null)

Get all (recursive) of the directories within a given directory.

Parameters

string|null $directory

Return Value

array

bool makeDirectory(string $path)

Create a directory.

Parameters

string $path

Return Value

bool

bool deleteDirectory(string $directory)

Recursively delete a directory.

Parameters

string $directory

Return Value

bool