composer require 3brs/imgproxy-bundle
Register the bundle in config/bundles.php:
return [
// ...
ThreeBRS\ImgproxyBundle\ThreeBRSImgproxyBundle::class => ['all' => true],
];
Create config/packages/three_brs_imgproxy.yaml:
imports:
- { resource: "@ThreeBRSImgproxyBundle/Resources/config/packages/three_brs_imgproxy.yaml" }
# Imgproxy server URL
IMGPROXY_URL=https://imgproxy.your-domain.com
# Source images URL (your S3/CDN endpoint)
IMGPROXY_SOURCE_URL=https://your-bucket.s3.amazonaws.com
# S3 prefix path (optional, leave empty if images are in bucket root)
IMGPROXY_SOURCE_PREFIX=media/image
# Optional: URL signing keys
IMGPROXY_KEY=your_hex_key_here
IMGPROXY_SALT=your_hex_salt_here
In config/packages/liip_imagine.yaml, change the cache resolver:
liip_imagine:
resolvers:
imgproxy:
# Resolver is auto-configured by the bundle
cache: imgproxy # Change from 'default' to use imgproxy resolver
filter_sets:
# Your existing filter sets...
thumbnail:
filters:
thumbnail: { size: [300, 200], mode: outbound }
php bin/console cache:clear
See imgproxy documentation for Kubernetes, AWS ECS, or other deployment options.
| Liip Imagine Filter | Imgproxy Equivalent | Notes |
|---|---|---|
thumbnail |
resize:fill or resize:fit |
Most commonly used |
resize |
resize:force + size |
Exact dimensions |
scale |
resize:fit + size |
Proportional scaling |
downscale |
resize:fit + enlarge:0 |
Never enlarges |
upscale |
resize:fit + enlarge:1 |
Always enlarges |
crop |
resize:fill + size |
Crop to dimensions |
rotate |
rotate |
Angle in degrees |
auto_rotate |
auto_rotate:1 |
EXIF-based rotation |
background |
background + extend |
Background color |
grayscale |
saturation:0 |
Grayscale effect |
watermark |
watermark |
Requires URL |
strip |
✓ | Automatic |
interlace |
✓ | Automatic |
relative_resize - May be imprecise (requires source dimensions)flip - No native imgproxy support (use CSS transform)paste - Complex compositing not supportedresample - DPI changes irrelevant for webNo changes to your templates are needed! All existing imagine_filter calls work automatically:
{# Works exactly as before #}
<img src="{{ asset('/media/image.jpg')|imagine_filter('thumbnail') }}" />
{# With responsive images #}
<picture>
<source srcset="{{ asset('/media/image.jpg')|imagine_filter('thumbnail_webp') }}" type="image/webp">
<img src="{{ asset('/media/image.jpg')|imagine_filter('thumbnail') }}" />
</picture>
┌─────────────────┐
│ Twig Template │
│ imagine_filter │
└────────┬────────┘
│
v
┌─────────────────────┐
│ Imgproxy Bundle │
│ (Cache Resolver) │
└────────┬────────────┘
│
v
┌─────────────────────┐ ┌──────────────┐
│ Imgproxy Server │◄─────│ S3 / CDN │
│ (Image Processing) │ │ (Source) │
└────────┬────────────┘ └──────────────┘
│
v
┌─────────────────────┐
│ Generated URL │
│ (Signed/Unsigned) │
└─────────────────────┘
Example Generated URLs:
# Without signing (development)
https://imgproxy.example.com/insecure/resize:fill:300:200/plain/s3-bucket.com/image.jpg
# With signing (production)
https://imgproxy.example.com/AbC123.../resize:fill:300:200/plain/s3-bucket.com/image.jpg
Using imgproxy provides significant performance improvements:
The bundle automatically detects and skips static assets (webpack builds, bundles):
/build/** - webpack encore assets/bundles/** - Symfony bundle assets/assets/** - general static filesThese are returned without imgproxy processing.
git clone https://github.com/3BRS/imgproxy-bundle.git
cd imgproxy-bundle
composer install
make up
Run make help to see all available commands:
make install # Install composer dependencies
make test # Run all tests (PHPUnit + ECS + PHPStan + Deptrac)
make phpunit # Run PHPUnit tests
make phpunit-coverage # Run tests with coverage report
make ecs # Check code style
make ecs-fix # Fix code style issues
make phpstan # Run static analysis
make deptrac # Run architecture analysis (requires PHP 8.1+)
make rector # Check for automated refactoring opportunities
make rector-fix # Apply automated refactorings
make audit # Check for security vulnerabilities (optional)
make bash # Connect to PHP container
Run the complete test suite:
# Run all quality checks
make test
# Or run individually
make phpunit # Unit tests
make ecs # Code style check
make phpstan # Static analysis
make deptrac # Architecture analysis (PHP 8.1+)
The project has comprehensive test coverage with 106 tests and 381 assertions:
# Run all tests
make phpunit
# Run only unit tests
make phpunit-unit
# Run only integration tests
make phpunit-integration
# Generate HTML coverage report
make phpunit-coverage
# Coverage report will be in var/coverage/index.html
Test Coverage:
Rector automatically refactors code to modern PHP standards:
# Check for refactoring opportunities
make rector
# Apply automated improvements
make rector-fix
What Rector improves:
Notes:
Note: Security audit is primarily useful for applications, not libraries/bundles.
This bundle doesn't commit composer.lock, so the audit only checks development dependencies.
For bundle developers:
make audit # Optional: checks dev dependencies (PHPStan, ECS, etc.)
For application developers using this bundle:
Always run security audit in your application to check all dependencies including this bundle:
# In your Symfony application
composer audit
The audit checks dependencies against the PHP Security Advisories Database.
The project uses CircleCI to test against multiple PHP and Symfony versions:
--prefer-lowest and --prefer-stableEach CI build runs:
Architecture Layers:
The project uses Deptrac to enforce clean architecture:
Version-specific tools:
We welcome contributions! Please follow these guidelines:
git checkout -b feature/amazing-feature)make test)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)All contributions must pass our quality gates:
Before submitting:
make test # Run all quality checks
make rector # Check for refactoring opportunities
make rector-fix # Apply automated improvements (optional)
This project is licensed under the MIT License.
Developed and maintained by 3BRS
How can I help you explore Laravel packages today?