- PHP 100%
- PHP ^8.2, Laravel ^11||^12 constraints - strict_types + type hints throughout - Dropped legacy Bootstrap views; consumer renders directly from the documented session keys - Dropped the unused icon parameter, simplified message() signature - Removed deferred-provider artifacts ($defer, provides()) - Facade gains @method docblocks for IDE autocomplete - Stripped stale .gitkeep / phpunit.xml / duplicate readme.md - Modernized README with the session-key contract + render example Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| src | ||
| .gitattributes | ||
| .gitignore | ||
| composer.json | ||
| LICENSE.md | ||
| README.md | ||
Laravel Flash Notifications
Tiny fluent helper for stashing a single one-shot flash message in the Laravel session for the next request to render. No bundled views, no opinion on your CSS framework, just session keys you can render any way you like. Tested on Laravel 11 and 12.
Installation
composer require lithiumhosting/laravel-flash-notifications
The service provider and Flash facade alias auto-register.
Usage
// Helper
flash()->success('Saved');
flash()->error('Could not save');
flash()->warning('Heads up')->important();
flash()->info('FYI');
flash()->overlay('Modal-style message', 'Title');
// Or via the facade
Flash::success('Saved');
Every flash call writes the following session keys, scoped to the next request:
| Session key | Always set | Purpose |
|---|---|---|
flash_notification.title |
yes | Heading text |
flash_notification.message |
yes | Body text |
flash_notification.level |
yes | success / danger / warning / info |
flash_notification.overlay |
optional | Render as a modal instead of an inline alert |
flash_notification.important |
optional | Don't auto-dismiss |
flash_notification.page |
optional | Page-level (not action-scoped) flash |
flash_notification.autoclose |
optional | Hint that the renderer can auto-dismiss |
Rendering
You own the render. A minimal Blade partial:
@if (session()->has('flash_notification.message'))
<div class="alert alert-{{ session('flash_notification.level', 'info') }}">
<strong>{{ session('flash_notification.title') }}</strong>
<p>{!! session('flash_notification.message') !!}</p>
</div>
@endif
@include that partial wherever your layout's flash slot lives.
License
This package, laravel-flash-notifications is licensed under The MIT License (MIT). Please see License File for more information.
Is it any good?
Yes.
When people first hear about a new product, they frequently ask if it is any good. A Hacker News user remarked:
Note to self: Starting immediately, all raganwald projects will have a "Is it any good?" section in the readme, and the answer shall be "yes.".