zendframework/zend-mvc-plugin-flashmessenger
Zend Framework MVC plugin that provides a flash messenger for carrying short status messages across redirects. Messages are stored in the session for the next request and then cleared automatically, making it easy to show success or error notices in your views after a redirect.
This is not a Laravel package — it ships zend-mvc-plugin-flashmessenger, a controller plugin + view helper for Zend Framework / zend-mvc. Requiring it in a Laravel app does nothing useful: there is no service provider, no facade, no auto-discovery, and the classes expect a zend-mvc ServiceManager and Zend\Session container. Treat it as a package you touch when maintaining a legacy ZF application alongside your Laravel work.
composer require zendframework/zend-mvc-plugin-flashmessenger:^1.2Zend\Mvc\Plugin\FlashMessenger\FlashMessenger (add/get/render messages) and the view helper Zend\Mvc\Plugin\FlashMessenger\View\Helper\FlashMessenger (markup rendering in .phtml templates).zend-stdlib v2 is no longer supported (you must be on v3), and a new Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait gives you IDE autocompletion for $this->flashMessenger() inside templates.redirect()->with() + a Blade partial.The Laravel equivalent you'll actually write day-to-day:
return redirect()->route('orders.index')->with('success', 'Order created.');
@if (session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
The value of this package to you is understanding the ZF contract so a bridge/shim or a port behaves identically.
1. Controller-side flash (ZF). Messages are queued during the request, persisted to the session on dispatch, and read back on the next request:
$this->flashMessenger()->addSuccessMessage('Order created.');
$this->flashMessenger()->addErrorMessage('Payment declined.');
// Namespaced messages for a specific form/flow
$this->flashMessenger()->addMessage('Saved as draft.', 'orders');
return $this->redirect()->toRoute('orders');
2. View-side rendering with markup classes. The helper takes a namespace and CSS classes, so it slots straight into Bootstrap-style layouts:
// layout.phtml
echo $this->flashMessenger()->render('success', ['alert', 'alert-success']);
echo $this->flashMessenger()->render('error', ['alert', 'alert-danger']);
echo $this->flashMessenger()->render('orders', ['alert', 'alert-info']);
3. IDE autocompletion (new in 1.2.0). Add the trait to your template's docblock so $this resolves helper methods:
<?php /** @var \Zend\View\Renderer\PhpRenderer|\Zend\Mvc\Plugin\FlashMessenger\View\HelperTrait $this */ ?>
This is the ZF analogue of Laravel's @method/@property docblocks and _ide_helper.php — purely developer experience, no runtime effect.
4. Bridge pattern when you run both frameworks. If you must surface ZF-generated flashes inside a Laravel view during a migration, normalise at the boundary rather than copying markup:
// Legacy ZF side: write to the shared session under a stable key
$this->flashMessenger()->addMessage($msg, 'laravel_bridge');
// Laravel side: a small view composer / Blade component reads that key once
// and clears it, mirroring the "one request only" flash semantics.
5. Laravel-native pattern to mirror it. Prefer framework primitives in Laravel rather than pulling zend-mvc in:
session()->flash('status', 'Profile updated.'); // survives one request
session()->now('status', 'Saved.'); // available immediately
session()->reflash(); // extend lifetime
6. Standardise your own helper. In either stack, wrap rendering in one component (<x-flash />) so success/error/warning markup is defined once and tests can assert against a single entry point.
composer.json hoping for auto-discovery; you'd get dead weight and possible Zend\Stdlib conflicts.zendframework/zend-stdlib:^2, upgrading this package will break resolution. Check composer why zendframework/zend-stdlib before bumping.laminas/laminas-mvc-plugin-flashmessenger, which is where PHP 8.x support lives. Plan the rename on any long-lived ZF app.SessionManager isn't configured or the session isn't started, messages silently disappear between requests — a common "why is my flash empty?" bug. Verify the session container, not the plugin.addMessage($msg, 'orders') requires render('orders'); rendering the default namespace shows nothing and vice versa. Always pass the namespace explicitly.FlashMessenger and add addWarningMessage()/addInfoMessage() plus convenience accessors, then register it in controller_plugins. This keeps render() calls symmetric.addMessage with the right namespace rather than asserting on rendered HTML. In Laravel, the equivalent is assertSessionHas('success', ...) — write the assertion style you'd want after a port so migration doesn't rewrite tests.ViewHelperTrait is docblock-only. It changes no behaviour and cannot break your templates, so it's a safe upgrade on its own — the real reason to pause on 1.2.0 is the stdlib constraint.How can I help you explore Laravel packages today?