goldenline/imgix-bundle
Symfony bundle for Imgix integration that helps generate signed image URLs with resizing, cropping, and format options, simplifying responsive image delivery through configuration and Twig helpers.
This is a Symfony bundle, not a Laravel package — there is no service provider, facade, or Blade integration. If you're working in Laravel, you have two options: (a) use imgix/imgix-php directly in a small service provider + facade, or (b) read this bundle as a reference implementation and copy its ~100 lines of config/Twig glue into Blade directives. Don't try to install it into a Laravel app expecting it to boot.
If you are in Symfony (or evaluating for a Symfony service you maintain):
Check constraints before installing. The package has 0 stars and 0 dependents, so treat it as unmaintained until proven otherwise. Open composer.json on GitHub and confirm the symfony/* and php version ranges match your app. Then composer require goldenline/imgix-bundle.
Register the bundle — config/bundles.php on Symfony 4+, AppKernel::registerBundles() on older versions.
Configure a source: domain (e.g. your-source.imgix.net), HTTPS flag, and signing key if the source is secured. Put the sign key in an env var, never in YAML.
Look at two files first: DependencyInjection/Configuration.php (the real config tree — trust it over the README) and the Twig extension (the actual filter/function names it registers). Those two files are ~90% of the bundle's surface area.
First use case: you store relative asset paths in the database (products/hero.jpg), and in a template you render an <img> with transformation params:
<img src="{{ 'products/hero.jpg'|imgix_url({ w: 800, auto: 'format', q: 75 }) }}"
alt="Hero">
Or, in Laravel with the underlying library directly:
$builder = new \Imgix\UrlBuilder('your-source.imgix.net');
$builder->setUseHttps(true);
$url = $builder->createURL('products/hero.jpg', ['w' => 800, 'auto' => 'format']);
Inject the builder, not the container. The bundle exposes an Imgix\UrlBuilder-shaped service. Type-hint that (or the bundle's service ID) in your controllers and domain services.
Wrap it in a preset layer. Raw per-call param arrays scatter magic numbers across templates. Define named presets once:
final class ImageUrlGenerator
{
private const PRESETS = [
'thumb' => ['w' => 200, 'h' => 200, 'fit' => 'crop', 'auto' => 'format'],
'hero' => ['w' => 1600, 'auto' => 'format', 'q' => 75],
'og' => ['w' => 1200, 'h' => 630, 'fit' => 'crop'],
];
public function __construct(private UrlBuilder $builder) {}
public function url(string $path, string $preset, array $overrides = []): string
{
return $this->builder->createURL($path, self::PRESETS[$preset] + $overrides);
}
}
Responsive images. Generate srcset from a fixed width ladder and always pair it with sizes. imgix-php has createSrcSet() / createSrcSetPair() — use them rather than hand-rolling string concatenation, and sort/dedupe widths ascending.
Store paths, not URLs. Persisting https://source.imgix.net/foo.jpg?w=800 in the DB bakes your CDN domain and params into your data. Store foo.jpg, generate at render time. Switching domains between staging and prod then becomes a config-only change.
Local/dev fallback. In dev you often have no imgix source. Configure the domain as null and have your generator fall back to asset($path) so the app still renders without network access to imgix.
Test with exact strings. Unit-test the generator with a fixture key and assert full URLs (assertSame). URL-generation bugs are silent — a wrong param just looks like a low-quality image. Snapshot tests catch accidental preset changes.
Extend by decoration. Add defaults (auto=format, q=75) globally by decorating the bundle's builder service with a small class that merges defaults before delegating, instead of editing templates everywhere.
imgix-php, that's a half-day job, not a migration.q, auto) invalidates every previously cached URL at the imgix edge. Expected — just don't do it casually on a high-traffic deploy.403 almost always means signature mismatch (wrong key, or signing enabled on the source but not in config, or vice versa). 404 means domain/path problem. Open the generated URL in the imgix dashboard's preview to isolate which.use_https is off you'll ship mixed-content images that browsers silently block. Set it explicitly, don't rely on a default.srcset ordering. Browsers expect ascending widths; duplicates waste bandwidth. Enforce it in code, not by convention.Imgix\UrlBuilder yourself — the bundle adds convenience, not capability.How can I help you explore Laravel packages today?