Gaufrette Extras
Extra Gaufrette features, including a filesystem decorator that resolves object keys to URLs
Repository Health
Technical Analysis
Gaufrette Extras extends the Gaufrette PHP filesystem abstraction with functionality that the core library leaves out, most notably a ResolvableFilesystem. This decorator wraps an existing Gaufrette filesystem and lets you turn a stored object key into a usable public or temporary URL.
It ships pluggable resolvers for Amazon S3 public URLs, S3 presigned (time-limited) URLs, and static base-URL mapping, so you can hand clients a direct link to a file without proxying the bytes through your application. The decorator pattern keeps your storage code unchanged while adding URL resolution on top.
What You Get
- A
ResolvableFilesystemdecorator that adds URL resolution to any Gaufrette filesystem AwsS3PublicUrlResolverfor permanent public S3 object URLsAwsS3PresignedUrlResolverfor time-limited, signed S3 URLsStaticUrlResolverfor mapping keys onto a fixed base URL (e.g. a CDN)- A
ResolverInterfaceyou can implement for custom URL schemes
Common Use Cases
- Generating direct download links for files stored in S3
- Issuing expiring presigned URLs for private S3 objects
- Serving assets through a CDN base URL mapped from storage keys
- Avoiding proxying large files through PHP by handing clients direct URLs
Under The Hood
Architecture - The library is organized under a single Gaufrette\Extras\Resolvable namespace. ResolvableFilesystem composes a decorated Filesystem and a ResolverInterface; its resolve() call forwards the object key to the injected resolver, which constructs a URL. Concrete resolvers (AwsS3PublicUrlResolver, AwsS3PresignedUrlResolver, StaticUrlResolver) live under Resolvable/Resolver, and failures surface as ResolverException/UnresolvableObjectException.
Tech Stack - Pure PHP with PSR-4 autoloading, requiring knplabs/gaufrette ~0.4 at runtime and using the AWS SDK for PHP (v2 or v3) at dev/integration time for the S3 resolvers. Testing uses phpspec and PHPUnit.
Code Quality - Despite its small size (~20 KB of PHP) the project maintains both a spec/ (phpspec) and tests/ suite mirroring the Resolvable structure, plus Scrutinizer quality tracking referenced in the README. Interfaces and dedicated exception types keep the design cleanly extensible.
API Design - The API is a single decorator plus a one-method resolver interface, so adopting it means wrapping your existing filesystem and picking a resolver. The README’s short, copy-pasteable example gets you from an S3 client to a resolvable URL in a few lines, keeping the learning curve low.