FilesystemAdapter

Class FilesystemAdapter

package

Default

Methods

FilesystemAdapter constructor.

__construct(\League\Flysystem\FilesystemInterface $driver) 

Arguments

$driver

\League\Flysystem\FilesystemInterface

Register a plugin.

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

Arguments

$plugin

\League\Flysystem\PluginInterface

The plugin to register.

Response

\League\Flysystem\FilesystemInterface

Copy a file.

copy(string $path, string $newpath) : boolean
Throws
\FileNotFoundException

Thrown if $path does not exist.

\FileExistsException

Thrown if $newpath exists.

Arguments

$path

string

Path to the existing file.

$newpath

string

The new path of the file.

Response

boolean

True on success, false on failure.

Create a directory.

createDir(string $dirname, array $config = array()) : boolean

Arguments

$dirname

string

The name of the new directory.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Delete a file.

delete(string $path) : boolean
Throws
\FileNotFoundException

Arguments

$path

string

Response

boolean

True on success, false on failure.

Delete a directory.

deleteDir(string $dirname) : boolean

Arguments

$dirname

string

Response

boolean

True on success, false on failure.

Get a file/directory handler.

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

Arguments

$path

string

The path to the file.

$handler

\Handler

An optional existing handler to populate.

Response

\Handler

Either a file or directory handler.

getAdapter

getAdapter() 

Get a file's mime-type.

getMimetype(string $path) : string|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

string|false

The file mime-type or false on failure.

Get a file's size.

getSize(string $path) : integer|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

integer|false

The file size or false on failure.

Get a file's timestamp.

getTimestamp(string $path) : string|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

string|false

The timestamp or false on failure.

Get a file's visibility.

getVisibility(string $path) : string|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

string|false

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

Check whether a file exists.

has(string $path) : boolean

Arguments

$path

string

Response

boolean

List contents of a directory.

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

Arguments

$directory

string

The directory to list.

$recursive

boolean

Whether to list recursively.

Response

array

A list of file metadata.

Create a file or update if exists.

put(string $path, string $contents, array $config = array()) : boolean

Arguments

$path

string

The path to the file.

$contents

string

The file contents.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Create a file or update if exists.

putStream(string $path, resource $resource, array $config = array()) : boolean
Throws
\InvalidArgumentException

Thrown if $resource is not a resource.

Arguments

$path

string

The path to the file.

$resource

resource

The file handle.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Read a file.

read(string $path) : string|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

string|false

The file contents or false on failure.

Read and delete a file.

readAndDelete(string $path) : string|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

string|false

The file contents, or false on failure.

Retrieves a read-stream for a path.

readStream(string $path) : resource|false
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

Response

resource|false

The path resource or false on failure.

Rename a file.

rename(string $path, string $newpath) : boolean
Throws
\FileNotFoundException

Thrown if $path does not exist.

\FileExistsException

Thrown if $newpath exists.

Arguments

$path

string

Path to the existing file.

$newpath

string

The new path of the file.

Response

boolean

True on success, false on failure.

Set the visibility for a file.

setVisibility(string $path, string $visibility) : boolean
Throws
\FileNotFoundException

Arguments

$path

string

The path to the file.

$visibility

string

One of 'public' or 'private'.

Response

boolean

True on success, false on failure.

Update an existing file.

update(string $path, string $contents, array $config = array()) : boolean
Throws
\FileNotFoundException

Arguments

$path

string

The path of the existing file.

$contents

string

The file contents.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Update an existing file using a stream.

updateStream(string $path, resource $resource, array $config = array()) : boolean
Throws
\FileNotFoundException
\InvalidArgumentException

If $resource is not a file handle.

Arguments

$path

string

The path of the existing file.

$resource

resource

The file handle.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Write a new file.

write(string $path, string $contents, array $config = array()) : boolean
Throws
\FileExistsException

Arguments

$path

string

The path of the new file.

$contents

string

The file contents.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Write a new file using a stream.

writeStream(string $path, resource $resource, array $config = array()) : boolean
Throws
\FileExistsException
\InvalidArgumentException

If $resource is not a file handle.

Arguments

$path

string

The path of the new file.

$resource

resource

The file handle.

$config

array

An optional configuration array.

Response

boolean

True on success, false on failure.

Properties

driver

driver : \League\Flysystem\FilesystemInterface
var

Type(s)

\League\Flysystem\FilesystemInterface