Provides a Gaufrette integration for your Symfony projects.
Gaufrette is a PHP library providing a filesystem abstraction layer. This abstraction layer allows you to develop applications without needing to know where all their media files will be stored or how.
Documentation is available the official page of Gaufrette.
composer require knplabs/knp-gaufrette-bundle
Register the bundle
You must register the bundle in your kernel:
<?php return [ // ... Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], ];
The Gaufrette bundle allows you to declare your filesystems as services without having to reach into the famous "Service Container". Indeed, you can do it with the configuration!
The configuration of the Gaufrette bundle is divided into two parts: the
adapters and the
Configuring the Adapters
# config/packages/knp_gaufrette.yaml knp_gaufrette: adapters: foo: local: directory: /path/to/my/filesystem
The defined adapters are then used to create the filesystems.
You can use on of these adapters:
- Local Adapter
- Safe Local Adapter
- In Memory
- Azure Blob Storage
- Phpseclib Sftp
- AWS S3
- Open Cloud
- Stream Wrapper
- Doctrine DBAL
Configuring the Filesystems
# config/packages/knp_gaufrette.yaml knp_gaufrette: adapters: # ... filesystems: bar: adapter: foo alias: foo_filesystem
Each defined filesystem must have an
adapter with its value set to an adapter's key.
The filesystem defined above will result in a service with id
alias parameter allows us to define an alias for it (
foo_filesystem in this case).
The filesystem map
You can access all declared filesystems through the map service.
In the previous exemple, we declared a
bar instance of
Check out basic examples of the library.