| Install | |
|---|---|
composer require rzl-app/laravel-toaster |
|
| Latest Version: | v1.1.0 |
| PHP: | ^8.2 |
__ __ _ _______
\ \ / /__ _ __ ___ | |_ ___ ___ ___ \ \ ___ ___ ___
\ \ /\ / / _ \| '__/ _ \ | __/ _ \/ __/ __| / | \ / __/ _ \/ __|
\ V V / (_) | | | __/ | || __/\__ \__ \ / | \ (_| __/\__ \
\_/\_/ \___/|_| \___| \__\___||___/___/ \____|__ /\___\___||___/
\/ \/
🚀 Rzl App Laravel Toaster 🚀
A clean, powerful Laravel Session Flash & Props Toaster helper —
perfect for Blade, Vue, React, Inertia, Livewire, or plain API.
Built with ❤️ by @rzl-app.
Laravel Framework & illuminate/support |
PHP | Package Version |
|---|---|---|
| ^9.x | ^10.x | ^11.x | ^12.x | ^8.2 | v1.1.x |
| ^9.x | ^10.x | ^11.x | ^8.1 | v1.0.x |
composer require rzl-app/laravel-toaster
php artisan vendor:publish --tag="RzlLaravelToaster"
Will create config/rzl-laravel-toaster.php:
return [
/*
|--------------------------------------------------------------------------
| Session Flash Name for Toaster
|--------------------------------------------------------------------------
|
| This defines the session key name used to flash the toaster data.
| It will be retrieved on the frontend after a redirect or page reload.
|
| Note: The Value must be string and not empty or only space or as blank
| value, if invalid value will return fallback as "toast".
|
| Default: 'toast'
|
| Example:
| session()->flash('toast', [...]);
|
*/
'session_name' => "toast",
/*
|--------------------------------------------------------------------------
| Settings Toaster Options As Session Flash or Only Return As Props Array.
|--------------------------------------------------------------------------
|
| Toaster Mode: Flash Session or Return as Props Array
| Return Format:
|
| * false: `Session` -> `session()->flash("toast", [
| $title, $message, $type, $durationClose
| ]);`
|
| * true: Props json output or array.
|
*/
'as_prop' => false,
];
toaster('Profile saved!');
toaster('Unauthorized action!', 'error', 5000);
toaster('Heads up!', 'warning', 0); // No auto close
toasterSuccess('Data saved!');
toasterError('Something wrong...');
toasterInfo('Heads up!');
toasterWarning('Careful!');
return [
'toast' => toasterAsProps('Welcome back!', 'info')
];
or shortcuts:
return response()->json([
'toast' => toasterErrorAsProps('Invalid data!')
]);
@if(session('toast'))
<script>
window.toast = @json(session('toast'));
console.log('Toast:', window.toast);
</script>
@endif
{
"title": "success_1725459999",
"message": "Profile updated",
"type": "success",
"durationClose": 2000,
"timeGenerate": 1725459999
}
✅ Use session for simple Laravel + Blade / Livewire.
✅ Use props for Inertia, SPA, or pure API.
✅ Set as_prop true in config to force always JSON array.
Help support development:
See CHANGELOG.
See CONTRIBUTING.
Please report issues to rizalvindwiky@gmail.com.
The MIT License (MIT). Please see License File for more information.
✅ Enjoy using rzl-app/laravel-toaster?
Star this repo ⭐ and share it with other Laravel developers!