somehow-digital / imgproxy
imgproxy URL builder for PHP.
v1.1.1
2026-11-09 17:28 UTC
Requires
- php: ^8.2
- ext-openssl: *
Requires (Dev)
- deptrac/deptrac: ^4.7
- ergebnis/composer-normalize: ^2.56
- mockery/mockery: ^1.6
- pestphp/pest: ^3.0 || ^4.0 || ^5.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- rector/rector: ^2.0
- roave/security-advisories: dev-latest
- shipmonk/composer-dependency-analyser: ^1.8
- shipmonk/phpstan-rules: ^4.0
- symplify/easy-coding-standard: ^13.0
- tomasvotruba/cognitive-complexity: ^1.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
imgproxy URL Builder is a PHP library for generating imgproxy
URLs in a type-safe, immutable, and composable way.
Features
- Immutable URL builder object
- Fluent API via method chaining
- Extensible test suite
- Supports all
imgproxyoptions - Supports
imgproxychained pipelines - Supports
imgproxysource URL masking - Supports
imgproxyURL signing
Installation
composer require somehow-digital/imgproxy
Usage
Basic URL
use SomehowDigital\ImgProxy\Url; $url = new Url(); $url = $url->source('https://example.com/image.jpg'); $url = $url->options( new Width(100), new Height(100), ); $url->build(); // _/w:100/h:100/plain/https%3A%2F%2Fexample.com%2Fimage.jpg
Chained pipeline
use SomehowDigital\ImgProxy\Url; $url = new Url(); $url = $url->source('https://example.com/image.jpg'); $url = $url->options( new Crop(1000, 1000), [ new Width(100), new Height(100), ], ); $url->build(); // _/c:1000:1000/-/w:100/h:100/plain/https%3A%2F%2Fexample.com%2Fimage.jpg
Base64-Encoded Source URL
use SomehowDigital\ImgProxy\Url; $url = new Url( new EncodingMasker(), ); $url = $url->source('https://example.com/image.jpg'); $url = $url->options( new Width(100), new Height(100), ); $url->build(); // _/w:100/h:100/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZS5qcGc
HMAC-Encrypted Source URL
use SomehowDigital\ImgProxy\Url; $url = new Url( new EncryptionMasker(ENCRYPTION_KEY), ); $url = $url->source('https://example.com/image.jpg'); $url = $url->options( new Width(100), new Height(100), ); $url->build(); // _/w:100/h:100/enc/p5VjorNdhs7mRRw8.jpg
Signed URL
use SomehowDigital\ImgProxy\Url; $url = new Url( new EncryptionMasker(ENCRYPTION_KEY), new Signer(SIGNATURE_KEY, SIGNATURE_SALT), ); $url = $url->source('https://example.com/image.jpg'); $url = $url->options( new Width(100), new Height(100), ); $url->build(); // oKfUtW34Dvo2BGQe/w:100/h:100/enc/p5VjorNdhs7mRRw8.png
Fluent API
use SomehowDigital\ImgProxy\Url; $url = Url::create( new EncryptionMasker(ENCRYPTION_KEY), new Signer(SIGNATURE_KEY, SIGNATURE_SALT), ) ->source('https://example.com/image.png') ->options( new Width(100), new Height(100), ) ->build(); // oKfUtW34Dvo2BGQe/w:100/h:100/enc/p5VjorNdhs7mRRw8.png