imgix/imgix-php
PHP client for building imgix image URLs with transformation params, optional HTTP/HTTPS, and support for signed URLs and srcset generation. Tested on PHP 8.0–8.2 and designed for reusable URL builders per imgix domain.
composer require imgix/imgix-phphttps://your-domain.imgix.net) and optionally your API signing key (required for secure URLs).
use imgix\UrlBuilder;
$builder = new UrlBuilder('https://your-domain.imgix.net', $apiKey = 'your-signing-key');
$url = $builder->createUrl('sample.jpg', [
'w' => 800,
'h' => 600,
'fit' => 'crop',
]);
// → https://your-domain.imgix.net/sample.jpg?w=800&h=600&fit=crop&s=...
First use case: Replace static image URLs in Blade views with dynamic, responsive, signed imgix URLs.UrlBuilder as a singleton in a service provider or helper function.imgix_url() helper for view-level usage:
function imgix_url(string $path, array $params = []): string {
return app(UrlBuilder::class)->createUrl($path, $params);
}
getSrcSet() to generate responsive srcset strings for <img> tags:
$srcset = $builder->getSrcSet('mountain.jpg', ['w' => [200, 400, 800]]);
// → '...200.jpg 200w, ...400.jpg 400w, ...800.jpg 800w'
fm + auto:
$url = $builder->createUrl('photo.jpg', [
'fm' => 'auto',
'q' => 70,
'w' => 1024,
]);
auto=format, q=75) in your UrlBuilder instance setup.IMGIX_API_KEY) and load conditionally (e.g., only in production).createUrl() merges params safely but does not deduplicate conflicting keys—ensure your code doesn’t accidentally pass duplicate keys (e.g., w twice).text or watermark) are auto-encoded, but for complex use cases (e.g., JSON in txt), manually rawurlencode() if needed.UrlBuilder in unit tests—don’t hit real endpoints.How can I help you explore Laravel packages today?