contenir / contenir-asset-laminas-mvc
Laminas MVC adapter for Contenir assets — keyed, profile-driven responsive image variants (incl. WebP/AVIF) backed by contenir/contenir-storage.
Package info
github.com/contenir/contenir-asset-laminas-mvc
pkg:composer/contenir/contenir-asset-laminas-mvc
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- contenir/contenir-storage: ^2.2
- laminas/laminas-cli: ^1.8
- laminas/laminas-http: ^2.0
- laminas/laminas-mvc: ^3.8
- laminas/laminas-router: ^3.0
- laminas/laminas-view: ^2.0
- psr/container: ^1.1 || ^2.0
- symfony/console: ^6.4.10 || ^7.1.3
Requires (Dev)
- infection/infection: ^0.34.1
- php-db/phpdb-qa-tools: 0.1.x-dev
- phpunit/phpunit: ^11.5.42
- symfony/string: ^6.4.10 || ^7.1.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main / 2.2.x-dev
- v2.2.0
- v2.1.0
- v2.0.0
- 0.x-dev
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.1
- v0.5.0
- 0.4.x-dev
- v0.4.3
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- v0.1.0
- dev-ci/push-trigger
- dev-chore/contenir-qa-tools
- dev-chore/tidy
- dev-chore/rename-storage-dependency
- dev-ci/infection
- dev-security/backport-0.x
- dev-fix/storage-2-resizer-interface
- dev-ci/contenir-qa-tools
- dev-v2/qa-tools
This package is auto-updated.
Last update: 2026-10-20 05:27:29 UTC
README
Laminas MVC module for Contenir assets: keyed, profile-driven responsive image variants (including WebP and AVIF) on top of contenir/contenir-storage.
A template names one profile (for example 'card') and gets the whole
responsive set: srcset ladder, sizes attribute and <picture> sources in
extra formats. The profiles are the same storage.variants declarations the
CMS and contenir/contenir-storage read, so there is one source of truth.
- View helpers:
storageSrcSet(),storageSizes(),storageSources()andstorageUrl(). - On-demand variants: a route and controller that generate a missing local variant on first request, and a secret-guarded endpoint an edge worker calls to generate a missing S3/R2 sibling.
- CLI:
storage:variantsto audit and backfill a backend.
Requirements
- PHP 8.3, 8.4 or 8.5
contenir/contenir-storage2.2+, formerlycontenir/storage(use contenir-asset-laminas-mvc 2.0 for storage 0.6)- laminas-mvc 3.8+, laminas-view 2, symfony/console 6.4.10+ or 7.1.3+, laminas-router 3, laminas-http 2, laminas-cli 1.8+
- ImageMagick (imagick extension or
magick/convertCLI) for local generation
Installation
composer require contenir/contenir-asset-laminas-mvc
With laminas/laminas-component-installer the module is registered for you;
otherwise add Contenir\Asset\Laminas\Mvc to config/modules.config.php.
Configuration
Everything lives under the storage key that contenir/contenir-storage reads:
'storage' => [ 'backend' => [ 'local' => ['type' => 'local', 'root_path' => 'public', 'public_path' => ''], // or an S3/R2 primary: ['type' => 's3', 'default' => true, 'publicUrl' => 'https://cdn…', 'generate_secret' => '…', …] ], 'variants' => [ 'admin-thumb' => ['width' => 180, 'height' => 180, 'fit' => 'contain'], 'card' => ['dimensions' => ['320x', '640x', '960x'], 'sizes' => '(min-width: 768px) 33vw, 100vw', 'formats' => ['avif', 'webp']], ], ],
The primary backend decides the URL scheme (_variant/<name>/ locally,
<key>__<name>.<ext> siblings on S3/R2). See docs/configuration.md.
Usage in templates
<picture>
<?= $this->storageSources($asset->path, 'card') ?>
<img srcset="<?= $this->storageSrcSet($asset->path, 'card') ?>"
sizes="<?= $this->storageSizes('card') ?>"
src="<?= $this->storageUrl($asset->path, 'card-320') ?>"
alt="">
</picture>
Documentation
Development
The QA toolchain is contenir/contenir-qa-tools.
Mago is a standalone binary, installed
separately (brew install mago).
composer check # everything below composer cs-check # mago format --check && mago lint composer static-analysis # mago analyze composer test # unit suite: no I/O, collaborators doubled composer test-integration # integration suite: real files, ImageMagick and Laminas containers composer test-coverage # both suites, clover.xml for Codecov composer mutation-test # Infection over both suites (needs Xdebug or PCOV)
License
MIT. See LICENSE.