Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Glide Symfony Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Image Controller Action: Create a dedicated controller action (e.g., /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 Integration: Enable cache via $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-based Image Delivery: Define routes like #[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).
  • Environment-Specific Handling: In development, disable caching or use memory adapters; in production, offload caching to Redis or a CDN.

Gotchas and Tips

  • Stream Rewinding: Before Glide 2, bugs in stream handling caused issues when streams weren’t rewound. Glide 2+ (and this adapter) now handles this, but ensure your Flysystem filesystem uses proper adapters (e.g., league/flysystem v3+ with proper stream() implementation).
  • Parameter Validation: Glide validates manipulation params internally (e.g., 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 Must Be Set Up: By default, Glide won’t write to disk unless a 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.
  • Symfony 7 & PHP 8.2+ Support: Version 2.0+ adds full support for modern PHP/Symfony versions, but ensure you’re not relying on deprecated BC layers (e.g., legacy cache interfaces). If upgrading, verify your custom CacheInterface implementations align with new PSR-6/16 practices.
  • Use 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport