Methods

has()

has(string  $path) : bool

Check whether a file exists.

Parameters

string $path

Returns

bool —

read()

read(string  $path) : string|false

Read a file.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

string|false —

The file contents or false on failure.

readStream()

readStream(string  $path) : resource|false

Retrieves a read-stream for a path.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

resource|false —

The path resource or false on failure.

listContents()

listContents(string  $directory = '', bool  $recursive = false) : array

List contents of a directory.

Parameters

string $directory

The directory to list.

bool $recursive

Whether to list recursively.

Returns

array —

A list of file metadata.

getMetadata()

getMetadata(string  $path) : array|false

Get a file's metadata.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

array|false —

The file metadata or false on failure.

getSize()

getSize(string  $path) : int|false

Get a file's size.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

int|false —

The file size or false on failure.

getMimetype()

getMimetype(string  $path) : string|false

Get a file's mime-type.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

string|false —

The file mime-type or false on failure.

getTimestamp()

getTimestamp(string  $path) : string|false

Get a file's timestamp.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

string|false —

The timestamp or false on failure.

getVisibility()

getVisibility(string  $path) : string|false

Get a file's visibility.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

string|false —

The visibility (public|private) or false on failure.

write()

write(string  $path, string  $contents, array  $config = []) : bool

Write a new file.

Parameters

string $path

The path of the new file.

string $contents

The file contents.

array $config

An optional configuration array.

Throws

\League\Flysystem\FileExistsException

Returns

bool —

True on success, false on failure.

writeStream()

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

Write a new file using a stream.

Parameters

string $path

The path of the new file.

resource $resource

The file handle.

array $config

An optional configuration array.

Throws

\InvalidArgumentException

If $resource is not a file handle.

\League\Flysystem\FileExistsException

Returns

bool —

True on success, false on failure.

update()

update(string  $path, string  $contents, array  $config = []) : bool

Update an existing file.

Parameters

string $path

The path of the existing file.

string $contents

The file contents.

array $config

An optional configuration array.

Throws

\League\Flysystem\FileNotFoundException

Returns

bool —

True on success, false on failure.

updateStream()

updateStream(string  $path, resource  $resource, array  $config = []) : bool

Update an existing file using a stream.

Parameters

string $path

The path of the existing file.

resource $resource

The file handle.

array $config

An optional configuration array.

Throws

\InvalidArgumentException

If $resource is not a file handle.

\League\Flysystem\FileNotFoundException

Returns

bool —

True on success, false on failure.

rename()

rename(string  $path, string  $newpath) : bool

Rename a file.

Parameters

string $path

Path to the existing file.

string $newpath

The new path of the file.

Throws

\League\Flysystem\FileExistsException

Thrown if $newpath exists.

\League\Flysystem\FileNotFoundException

Thrown if $path does not exist.

Returns

bool —

True on success, false on failure.

copy()

copy(string  $path, string  $newpath) : bool

Copy a file.

Parameters

string $path

Path to the existing file.

string $newpath

The new path of the file.

Throws

\League\Flysystem\FileExistsException

Thrown if $newpath exists.

\League\Flysystem\FileNotFoundException

Thrown if $path does not exist.

Returns

bool —

True on success, false on failure.

delete()

delete(string  $path) : bool

Delete a file.

Parameters

string $path

Throws

\League\Flysystem\FileNotFoundException

Returns

bool —

True on success, false on failure.

deleteDir()

deleteDir(string  $dirname) : bool

Delete a directory.

Parameters

string $dirname

Throws

\League\Flysystem\RootViolationException

Thrown if $dirname is empty.

Returns

bool —

True on success, false on failure.

createDir()

createDir(string  $dirname, array  $config = []) : bool

Create a directory.

Parameters

string $dirname

The name of the new directory.

array $config

An optional configuration array.

Returns

bool —

True on success, false on failure.

setVisibility()

setVisibility(string  $path, string  $visibility) : bool

Set the visibility for a file.

Parameters

string $path

The path to the file.

string $visibility

One of 'public' or 'private'.

Throws

\League\Flysystem\FileNotFoundException

Returns

bool —

True on success, false on failure.

put()

put(string  $path, string  $contents, array  $config = []) : bool

Create a file or update if exists.

Parameters

string $path

The path to the file.

string $contents

The file contents.

array $config

An optional configuration array.

Returns

bool —

True on success, false on failure.

putStream()

putStream(string  $path, resource  $resource, array  $config = []) : bool

Create a file or update if exists.

Parameters

string $path

The path to the file.

resource $resource

The file handle.

array $config

An optional configuration array.

Throws

\InvalidArgumentException

Thrown if $resource is not a resource.

Returns

bool —

True on success, false on failure.

readAndDelete()

readAndDelete(string  $path) : string|false

Read and delete a file.

Parameters

string $path

The path to the file.

Throws

\League\Flysystem\FileNotFoundException

Returns

string|false —

The file contents, or false on failure.

get()

get(string  $path, \League\Flysystem\Handler  $handler = null) : \League\Flysystem\Handler

Get a file/directory handler.

Parameters

string $path

The path to the file.

\League\Flysystem\Handler $handler

An optional existing handler to populate.

Returns

\League\Flysystem\Handler —

Either a file or directory handler.

addPlugin()

addPlugin(\League\Flysystem\PluginInterface  $plugin) : $this

Register a plugin.

Parameters

\League\Flysystem\PluginInterface $plugin

The plugin to register.

Returns

$this —