Architecture
It’s all about adapting.
Flysystem uses the adapter pattern. This pattern is especially useful for mediating API incompatibilities, so it’s a perfect fit for the use-case.
The League\Flysystem\FilesystemOperator
interface represents the outside
boundary. It defines how you should interact with Flysystem. This layer
providers common functionality that the underlying filesystem adapters
rely on.
The League\Flysystem\Filesystem
(the main filesystem operator implementation)
uses adapters to do the real work. Every adapter is an implementation of the
League\Flysystem\FilesystemAdapter
interface. Each of the adapters conform to
the same contract and behavior specifications (enforced by tests).
Consuming Flysystem
The League\Flysystem\FilesystemOperator
interface represents is most complete
interface to integrate with. You can distinguish between reads and writes by
hinting on the underlying interfaces:
- Reading:
League\Flysystem\FilesystemReader
- Writing:
League\Flysystem\FilesystemWriter
For any of the three interfaces, the composition will look like this:
|--- Your Code -----------------------------|
| |
|-> |--- Filesystem --------------------| |
| | | |
| |-> |--- Filesystem Adapter ----| | |
| | | | | |
| | |---------------------------| | |
| | | |
| |-----------------------------------| |
| |
|-------------------------------------------|