innmind / filesystem
Filesystem abstraction layer
Installs: 117 783
Dependents: 21
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
pkg:composer/innmind/filesystem
Requires
- php: ~8.2
- innmind/immutable: ~4.15|~5.0
- innmind/io: ^3.0.1
- innmind/media-type: ~2.1
- innmind/url: ~4.2
- innmind/validation: ~2.0
- psr/log: ~3.0
- symfony/filesystem: ~6.0|~7.0
Requires (Dev)
- innmind/black-box: ^6.0.2
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ^1.2.1
- ramsey/uuid: ^4.6
Suggests
- innmind/black-box: For property based testing
Provides
Conflicts
- innmind/black-box: <6.0|~7.0
- dev-develop
- 8.1.0
- 8.0.0
- 7.6.0
- 7.5.1
- 7.5.0
- 7.4.0
- 7.3.0
- 7.2.0
- 7.1.0
- 7.0.0
- 6.6.0
- 6.5.1
- 6.5.0
- 6.4.0
- 6.3.2
- 6.3.1
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.2.0
- 5.1.0
- 5.0.0
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-master
- dev-close-once-read
This package is auto-updated.
Last update: 2025-10-09 14:00:10 UTC
README
Filesystem abstraction layer, the goal is to provide a model where you design how you put your files into directories without worrying where it will be persisted.
Installation
composer install innmind/filesystem
Usage
The whole model is structured around files, directories, contents and adapters. File, Directory and Content are immutable objects.
Example:
use Innmind\Filesystem\{ File, File\Content, Directory, Adapter\Filesystem, }; use Innmind\Url\Path; $directory = Directory::named('uploads')->add( File::named( $_FILES['my_upload']['name'], Content::ofString(\file_get_contents($_FILES['my_upload']['tmp_name'])), ), ); $adapter = Filesystem::mount(Path::of('/var/www/web/')); $_ = $adapter ->add($directory) ->unwrap();
This example show you how you can create a new directory uploads in the folder /var/www/web/ of your filesystem and create the uploaded file into it.
Note: For performance reasons the filesystem adapter only persist to disk the files that have changed (achievable via the immutable nature of file objects).
All adapters implements Adapter, so you can easily replace them; especially for unit tests, that's why the library comes with an InMemory adapter that only keeps the files into memory so you won't mess up your file system.