v0.1.0 — Initial release
Session-free flash/toast notifications for Symfony that keep your pages HTTP-cacheable.
One addFlash() is enough to drag the session into an otherwise stateless page and make it uncacheable by Varnish or your CDN. This bundle takes the flash out of the session entirely.
Features
Two session-free transports
- Turbo Stream —
$this->toast('Item saved')returns atext/vnd.turbo-stream.htmlresponse that appends the toast to the DOM. No redirect, no storage at all. Refuses to render (with an actionableLogicException) when the request does not accept Turbo Streams. - Cookie —
$this->deferToast('Welcome back!')before a classicRedirectResponse: toasts are serialized into a short-lived cookie atkernel.responsetime and consumed client-side on the next page load. The redirected-to page stays cacheable.
Developer experience
TurboToastTraitfor controllers:toast(),toasts(),deferToast(){{ turbo_toast_container() }}Twig function renders the container div with Stimulus values injected from the bundle configuration — PHP config and JS can never drift apart- Two auto-registered Stimulus controllers:
toast(fade-in, auto-dismiss, click to dismiss) andtoast-container(cookie consumption on initial load and everyturbo:load) - Configurable: container id, controller name, default delay, stream template, cookie name
- Optional minimal stylesheet
Hardening
- Cookie:
SameSite=Lax,Secureon HTTPS, ~3.8 KB budget with graceful overflow, cleared before rendering so Turbo cache restores never replay a toast, rendered withtextContentonly (client-modifiable input) - Responses carrying the cookie are forced
privateso theSet-Cookienever enters a shared HTTP cache - 5xx responses discard queued toasts instead of promising success on the next page
ToastStackimplementsResetInterface(kernel.reset): no cross-request leak under FrankenPHP worker mode / RoadRunner / Swoole- Accessibility:
aria-live="polite"container,role="status"/role="alert"by toast type
Requirements
PHP >= 8.3, Symfony 7.x, symfony/ux-turbo + symfony/stimulus-bundle.
Installation
composer require marilenarm/turbo-toast-bundleSee the README for the full documentation, including the honest when (not) to use it section.