sirix/inertia-psr15-mezzio-flash

Mezzio flash-message bridge for inertia-psr15
62
Install
composer require sirix/inertia-psr15-mezzio-flash
Latest Version:1.0.0
PHP:~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
License:BSD-3-Clause
Last Updated:Aug 19, 2026
Links: GitHub  ·  Packagist
Maintainer: sirix777

inertia-psr15 Mezzio flash bridge

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Storage-neutral Mezzio flash-message integration for sirix/inertia-psr15 3.x. It adapts Mezzio\Flash\FlashMessagesInterface to the core public flash-provider contract. It does not install middleware, select a session backend, transform payloads, or write logs.

Installation

composer require sirix/inertia-psr15-mezzio-flash

The package is auto-discovered by laminas-component-installer. Ensure the session and flash middleware run before Inertia for every applicable path:

$app->pipe(\Mezzio\Session\SessionMiddleware::class);
$app->pipe(\Mezzio\Flash\FlashMessageMiddleware::class);
$app->pipe(\Sirix\InertiaPsr15\Middleware\InertiaMiddleware::class);

The default request attribute is FlashMessageMiddleware::FLASH_ATTRIBUTE (flash). Missing or incorrectly typed attributes fail fast with a typed bridge exception, which usually means the pipeline order or route coverage is incorrect.

Usage

For a response rendered in the same request, use the core API:

$inertia->flash('message', 'Profile saved');

return $inertia->render('Profile/Edit', ['profile' => $profile]);

For post-redirect-get, queue the flash value before returning a redirect:

$inertia->flash(['message' => 'User created', 'userId' => $user->id]);

return new \Laminas\Diactoros\Response\RedirectResponse('/users/' . $user->id);

Incoming Mezzio messages and direct values are exposed in Inertia v3's top-level page.flash; they are not copied to props.flash. On control responses (409 with X-Inertia-Location or X-Inertia-Redirect), the core persists pending direct data before this bridge prolongs incoming messages.

Configuration

The configuration provider registers only InertiaFlashProviderInterface and defaults to the flash request attribute. To use a different attribute name:

return [
    'inertia_psr15_mezzio_flash' => [
        'request_attribute' => 'application_flash',
    ],
];

The value must be a non-empty, control-character-free string. The adapter returns the native Mezzio payload unchanged; core validates safe keys and serializability.

Contributing

Run all checks with:

composer check

See CONTRIBUTING.md, SECURITY.md, and CHANGELOG.md.

Related Packages

sakanjo/laravel-flashy

Easy flash notifications for laravel

45 0
honed/flash

Create backend-driven flash messages for your Inertia application.

3,295 0
crenspire/yii3-inertia

Inertia.js adapter for Yii3 framework

32 1
middag-io/framework

MIDDAG PHP Framework — DDD kernel, container, Inertia adapter, router, form engi...

5,597 0