- Is short-edition/knp-gaufrette-bundle a Laravel package?
- No. It is a Symfony bundle that registers Gaufrette filesystems in the Symfony dependency injection container; there is no Laravel service provider, facade, or config bridge. Laravel already ships Flysystem through its native Storage facade, so pulling Gaufrette in means hand-rolling and owning an adapter layer yourself. If your application is Laravel, use Storage with the local, S3, or FTP drivers instead of this package.
- How do I install and register KnpGaufretteBundle in a Symfony application?
- Install it with Composer using composer require short-edition/knp-gaufrette-bundle, then register the bundle in config/bundles.php (or AppKernel for older Symfony versions). After registration, add a knp_gaufrette configuration block to your config directory listing your adapters and filesystems. The bundle's compiler passes then turn each configured filesystem into a container service automatically.
- How do I configure local, FTP, or S3 filesystems in YAML?
- You declare adapters and filesystems under the knp_gaufrette key: adapters define the backend type and its options (a local adapter needs a directory, an ftp adapter needs host, credentials, and root, an aws_s3 adapter needs bucket, key, and secret). Filesystems then reference an adapter by name and can add options such as a cache directory or create/remove permissions. Once configured, each filesystem is exposed as a service named gaufrette.<filesystem_name>.
- How do I inject a Gaufrette filesystem into my service or controller?
- Inject the service gaufrette.<name> directly, or inject gaufrette.filesystem_map and call get('name') when the filesystem choice is dynamic. Constructor injection with an explicitly named argument is preferable in Symfony because it keeps your dependencies visible and autowiring unambiguous. Avoid pulling services from the container at runtime unless you genuinely need to select a backend per request or per tenant.
- How does the gaufrette:// stream wrapper work and when should I use it?
- The bundle can register a gaufrette:// stream wrapper so native PHP functions such as file_get_contents, fopen, and copy work against any configured filesystem using a path like gaufrette://my_filesystem/path/to/file.txt. This is convenient for legacy code or third-party libraries that only accept a path rather than a filesystem object. Enable it deliberately, since it hides I/O errors behind PHP warnings and bypasses the typed Gaufrette API.
- How is this fork different from knplabs/knp-gaufrette-bundle, and is it safe to depend on?
- The short-edition package is a fork of the well-known upstream bundle with effectively no stars or dependents, so it carries no community validation. Before adopting it, diff it against the upstream tag it was forked from and confirm the baseline version, because low-traffic forks typically exist to carry a single hotfix against an old release. If you do proceed, pin the dependency to a specific commit SHA and track whether the patch ever lands upstream.
- Which PHP and Symfony versions does this bundle support?
- The compatibility ceiling is not documented for this fork, so check the composer.json constraints rather than assuming parity with upstream. Symfony bundles usually break at DI or bundle-interface changes across majors, so test against the exact Symfony major your application runs. Build a small matrix of PHP version, Symfony major, and the adapters you require before committing to it.
- Should I use Gaufrette or Flysystem for a new Symfony project?
- For greenfield Symfony work, league/flysystem-bundle is the safer default: Flysystem is actively maintained and has broader first-party adapter coverage. Gaufrette's filesystem abstraction is a reasonable shape, but the ecosystem around it has largely been ceded to Flysystem, so adopting it means investing in the trailing option. Choose Gaufrette only if you specifically need an adapter with no Flysystem equivalent, such as older GridFS or DBAL-backed paths.
- Can I use it to manage multiple storage backends or per-tenant buckets in one application?
- Yes, that is the bundle's strongest feature. Each entry under filesystems becomes its own named service and a member of the FilesystemMap, so you can define separate local, S3, or FTP filesystems and select one at runtime. This makes per-tenant or per-bucket isolation straightforward: store the filesystem name alongside the tenant and resolve it through the map.
- How do I test code that depends on a Gaufrette filesystem?
- Point your test environment configuration at a local adapter writing to a temporary directory, or use an in-memory adapter so assertions stay fast and hermetic. Because the filesystem is injected as a service, you can also mock the FilesystemInterface for pure unit tests of your own logic. Note that this fork's own test suite is unverified, so treat upstream's tests and your integration tests as the real safety net.