PHPackages                             contenir/contenir-asset-laminas-mvc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. contenir/contenir-asset-laminas-mvc

ActiveLibrary[Image &amp; Media](/categories/media)

contenir/contenir-asset-laminas-mvc
===================================

Laminas MVC adapter for Contenir assets — on-demand responsive image variants (incl. WebP/AVIF) backed by contenir/storage.

v0.1.0(yesterday)01↑2900%MITPHPPHP ^8.1 || ^8.2 || ^8.3

Since Jun 10Pushed yesterdayCompare

[ Source](https://github.com/contenir/contenir-asset-laminas-mvc)[ Packagist](https://packagist.org/packages/contenir/contenir-asset-laminas-mvc)[ RSS](/packages/contenir-contenir-asset-laminas-mvc/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

contenir/contenir-asset-laminas-mvc
===================================

[](#contenircontenir-asset-laminas-mvc)

Laminas MVC adapter for Contenir assets. Serves **on-demand responsive image variants** — including **WebP** and **AVIF** — backed by [`contenir/storage`](https://github.com/contenir/storage)'s `ImageResizer`.

This is the MVC flavour of the Contenir asset layer (the `core` + `-laminas-mvc`convention). The generation engine lives in `contenir/storage`; HTTP serving and the view helpers live here.

What it provides
----------------

[](#what-it-provides)

- **`AssetVariantController` + `assetvariant` route** — serves `/asset//_variant//`. Existing variant files are served directly by the web server; only missing ones reach the controller, which resizes on demand and streams the result.
- **View helpers** for templates:
    - `storageUrl($path, $dimensions = null, $format = null)` — a single URL (original, or a `_variant//` variant).
    - `storageSrcSet($path, $widths = null, $format = null)` — a responsive `srcset`over the configured width ladder.
    - `storageSources($path, $widths = null, $sizes = null)` — `` elements (AVIF, WebP) for a ``, with lazy `data-lazysrc-srcset` attributes.
- **`AssetUrlBuilder`** — the pure string URL builder behind the helpers. Returns **raw** URLs; escaping is the output context's job (`htmlAttributes()` escapes — escaping here too would double-encode).

URL scheme
----------

[](#url-scheme)

```
/asset//_variant//.

```

`` is `Wx` (width-bound, e.g. `480x`), `xH` (height-bound, e.g. `x900`), or `WxH` (e.g. `480x900`) — the same geometry vocabulary as ImageMagick. `` is the source extension, `webp`, or `avif`. The responsive `srcset` ladder emits `Wx` tokens.

A `WxH` request crops to fill (`Cover`); a single-axis request fits inside (`Contain`). When the requested format cannot be produced (e.g. the ImageMagick build lacks AVIF), the controller falls back to a source-format variant so the URL returns valid image bytes with the real `Content-Type` rather than a 404.

Installation
------------

[](#installation)

```
composer require contenir/contenir-asset-laminas-mvc
```

If you use `laminas/laminas-component-installer`, the module is registered automatically; otherwise add `Contenir\Asset\Laminas\Mvc` to `config/modules.config.php`.

Configuration
-------------

[](#configuration)

Override the defaults per-site in `config/autoload/storage.global.php`:

```
return [
    'storage' => [
        'asset' => [
            'root_path'       => 'public',
            'public_path'     => '',
            'variant_widths'  => [320, 480, 600, 760, 960, 1280, 1440, 1920, 2560],
            'variant_formats' => ['avif', 'webp'],
            // 'binary'       => '/opt/homebrew/bin/magick', // optional; auto-discovered otherwise
        ],
    ],
];
```

Usage in templates
------------------

[](#usage-in-templates)

```
