laracasts/flash
Simple flash messaging for Laravel apps by Laracasts. Easily set session-based success, info, warning, and error messages and display them in your views with a clean API and customizable templates. Great for notifications after redirects.
Install the package via Composer (composer require laracasts/flash), then ensure the service provider is auto-discovered (Laravel 5.5+ handles this automatically; for older versions, manually add Laracasts\Flash\FlashServiceProvider::class to config/app.php). No configuration changes required out of the box — start flashing messages in controllers or commands using flash():
// Basic success message
flash('User created successfully!')->success();
// Warning with extra context
flash('Incomplete profile details.')->warning();
// Overlay (modal-style) notification
flash('Welcome to your new dashboard!')->overlay();
In your Blade layout (typically resources/views/layouts/app.blade.php), include the notification partial once per page:
@if (session('flash_notification'))
@include('flash::message')
@endif
This renders the compiled message(s) on the next request after the flash is set — perfect for redirect-after-post workflows.
flash('text') with chained modifiers: success(), info(), warning(), error(), overlay(), and important() (for persistent dismiss behavior).flash('First message');
flash('Second')->info();
flash('Third')->error();
->overlay() to trigger modal-style messages via alpine-modal or custom JS — the package sets flash_notification in the session, accessible on next load.php artisan vendor:publish --provider="Laracasts\Flash\FlashServiceProvider" to modify markup, add your own CSS classes, or inject Alpine behaviors. Default view resides at vendor/laracasts/flash/src/views/message.blade.php.session('flash_notification') in JavaScript (e.g., via Axios response interceptors or form submit handlers).redirect()->back()) — messages won’t show on AJAX responses unless explicitly handled in JS.flash() after redirects.overlay() sets data-overlay="true" but doesn’t auto-open the modal — you must write frontend logic to detect and render it (e.g., Alpine component that checks session('flash_notification') on mount).3.2.4 supports Laravel 12, verify your view customizations don’t conflict with newer Blade syntax or session driver defaults (e.g., cookie encryption).->important() or customize your view template. Implement fade-outs via CSS transitions or JS instead.session()->all() for flash_notification — ensure no middleware clears the session, and confirm your layout includes the flash::message include.How can I help you explore Laravel packages today?