- Important Classes & Interfaces
- Important Directories
Filesystem is component that allows managing multiple filesystems and provides abstraction for various storage models.
- Abstraction for filesystem-related operations
- Mount manager for multiple filesystems
- Support for multiple storage models including clouds
- Kraken Framework compatibility
This section contains terminology, useful concepts and definitions, that might be helpful to learn to fully understand this component purpose.
Filesystem is an abstraction of methods manipulating on local and remote file and directory structure.
This section contains examples and patterns that can be used with described component.
To create filesystem you have to pass storage model for it to operate upon.
$fs = new Filesystem( (new FilesystemAdapterFactory)->create('Local'); );
Or alternatively, since
$fs = (new FilesystemFactory)->create('Local');
It is possible to mount multiple filesystems using
Kraken\Filesystem\FilesystemManager. Mounted filesystems will then be accessible using proper prefix.
$factory = new FilesystemFactory(); $manager = new FilesystemManager([ 'local' => $factory->create('Local', [[ 'path' => __DIR__ ]]), // this fs will be available with local:// prefix 'aws' => $factory->create('AwsS3v3', [ $config ]); // this fs will be available with aws:// prefix ]);
Operating On Filesystem
All operations on filesystem can be made via
$fs->createFile($path, "some text\n", $fs::VISIBILITY_PRIVATE);
Writing to files can be done by
append methods, for example:
$fs->append($path, "this will be added at the end\n");
For more options, please see
To list files use
$files = $fs->getFiles($path, true, $filter = "#\.php$#si");
This example will list all
.php files recursively in given path.
To list directories use
$dirs = $fs->getDirectories($path, $recursiveness, $filter);
Important Classes & Interfaces
This section contains list of most important classes and interfaces shipped with this component. It does not include all classes and interface.
class Filesystem implements FilesystemInterface
Loop is an abstraction layer for managing filesystem structure using various storage models. It wraps around the PHP League filesystem providing new, extended and Kraken-compatible interface, which has been redone with consistency in mind.
class FilesystemManager implements FilesystemManagerInterface
FilesystemManager is a special concrete object allowing you to create composition of filesystems and referencing all of them using one object.
interface FilesystemManagerInterface extends FilesystemInterface
class FilesystemAdapterFactory extends Factory implements FilesystemAdapterFactoryInterface
This factory allows you to create any filesystem adapter wrapping corresponding PHP League model.
interface FilesystemAdapterFactoryInterface extends FactoryInterface
This section contains list of most important directories existing inside of component. It does not include all directories.
Factory folder contains set of factories for creating variety of League Filesystem adapters for using Filesystem with cloud storage. All of them might be created using