league/glide-symfony
Symfony adapter for League Glide image manipulation. Easily integrate on-demand image resizing, cropping, and caching into Symfony apps with Glide’s server and filesystem support. Install via Composer and follow the official Glide documentation for setup.
Install the package via Composer: composer require league/glide-symfony. This package provides seamless integration between Glide image manipulation and Symfony’s HTTP stack — specifically, it includes a ResponseFactory to generate Symfony Response objects directly from processed images. Start by configuring Glide using Symfony’s config system (e.g., in config/packages/glide.yaml), defining source and target filesystems (typically Flysystem-backed), and optionally setting cache settings or default image manipulation parameters. Your first use case will likely be serving manipulated images via a controller action using the ResponseFactory, e.g., generating thumbnails or responsive images on demand.
/images/{path}) that receives Glide parameters (like w=200&h=150&fit=crop) and uses League\Glide\Symfony\ResponseFactory to produce a Symfony Response. Inject the factory via constructor or method injection, then call $responseFactory->createResponse($source, $params, $outputBuffer, $cache).$cache->save($sourcePath, $processedContents, $expires) using a Flysystem cache adapter (e.g., FilesystemAdapter). Glide Symfony automatically handles cache validation via If-Modified-Since headers when configured properly.#[Route('/img/{path}', name: 'img')] with fallback path resolution to abstract away /img and allow clean URLs (e.g., /img/original/path.jpg?w=400).league/flysystem v3+ with proper stream() implementation).w, h, fit), but ensure untrusted user input is filtered before passing to createResponse() — use Symfony’s Request query parameter handling to sanitize or validate.cache adapter is explicitly configured in Glide’s config array. Set up a cache filesystem (e.g., local or redis) in your config — otherwise, responses will regenerate on every request.CacheInterface implementations align with new PSR-6/16 practices.ResponseFactory::createResponse() for Performance: This helper sets proper headers (Content-Type, Cache-Control, ETag, Last-Modified) — avoid building Response manually unless you have specialized needs.How can I help you explore Laravel packages today?