Skip to content

Getting started

  • PHP 8.2 or newer
  • The openssl extension

You need a running imgproxy instance to serve the URLs. This library only builds them.

Terminal window
composer require somehow-digital/imgproxy
use SomehowDigital\ImgProxy\Option\Height;
use SomehowDigital\ImgProxy\Option\Width;
use SomehowDigital\ImgProxy\Url;
$url = Url::create()
->source('https://example.com/image.jpg')
->options(
new Width(100),
new Height(100),
);
$url->build();
// _/w:100/h:100/plain/https%3A%2F%2Fexample.com%2Fimage.jpg

build() returns the path of the URL. Prepend the address of your imgproxy instance to serve it:

$address = 'https://imgproxy.example.com/' . $url->build();

The leading _ is the placeholder imgproxy accepts when signing is not used.