Setup / Bootstrap

As explained in the architecture description, Flysystem uses the adapter pattern. This means you’ll always need an adapter, which needs to be wrapped in a Filesystem instance.

Adapter Setup

Each adapter has their own setup and dependencies. For each adapter a setup guide is provided. You can find the guides in the adapters section in the menu.

For this example we’ll use the local adapter:


use League\Flysystem\Adapter\Local;

$adapter = new Local(__DIR__.'/path/to/root/');

Setup Filesystem

Now that you’ve got your adapter setup you can use it to create the filesystem:


use League\Flysystem\Filesystem;

$filesystem = new Filesystem($adapter);

Global Configuration

Adapters each have their own configuration. Apart from adapter constructors configuration options can be provided in global configuration through the Filesystem.


use League\Flysystem\Filesystem;

$filesystem = new Filesystem($adapter, ['visibility' => 'public']);

The global available configuration options are:

option description type
visibility default visibility string
disable_asserts disable extra calls to assert whether or not a file exists, see Performance bool
case_sensitive whether or not the adapter’s file system is case sensitive, e.g. Dropbox is case insensitive bool