devrabiul/laravel-toaster-magic
Dependency-free toast notifications for Laravel with Livewire v3/v4 support. Drop-in, customizable toasts with multiple modern themes, RTL + dark mode, XSS-safe links, and no need for jQuery, Bootstrap, or Tailwind.
This release focuses on security hardening, bug fixes, and code quality improvements. No breaking changes — fully backward-compatible with v2.0.
customBtnLink values are now validated before being rendered into href attributes. Previously, a malicious value like javascript:... could execute arbitrary code when the button was clicked.
A sanitizeUrl() guard was added to both the standard and Livewire JS builds. Any URL that does not start with http://, https://, /, or # is automatically replaced with #.
Affected files:
assets/js/laravel-toaster-magic.jsassets/js/livewire-v3/laravel-toaster-magic.jsjavascript: Default in Livewire EventsThe Livewire event listener was using 'javascript:' as the default fallback for customBtnLink when none was provided. This has been replaced with an empty string, which correctly suppresses the button from rendering entirely.
php artisan migrate with Database Cache DriverFixes: #19
The service provider called Cache::rememberForever() during boot(). When CACHE_STORE=database, this immediately fired a SQL query against the cache table — but on a fresh installation the table doesn't exist yet, causing a fatal error that prevented php artisan migrate from running at all.
The fix wraps the cache call in a try-catch. If the cache driver throws for any reason (missing table, connection error, misconfigured driver), the value is computed directly without caching. Once migrations complete, normal caching resumes automatically.
// Before — crashes if cache table doesn't exist yet
$systemProcessingDirectory = Cache::rememberForever($cacheKey, $compute);
// After — falls back gracefully
try {
$systemProcessingDirectory = Cache::rememberForever($cacheKey, $compute);
} catch (\Throwable) {
$systemProcessingDirectory = $compute();
}
rtrim() Was Silently Corrupting Toast MessagesWhen building toast messages from a Laravel MessageBag, the code used rtrim($string, "<br>") to strip the trailing <br> separator. PHP's rtrim() treats its second argument as a character mask, not a string — meaning it was stripping any of the individual characters <, b, r, > from the right end of the message. Words like "error", "number", or "better" at the end of a validation message would be silently truncated.
Fixed with preg_replace('/(<br>)+$/', '', $string) across all four methods: info, success, warning, error.
closeButton OptionThe Livewire event listener only read showCloseBtn from event options, while the rest of the package used closeButton. Users passing closeButton: true in a Livewire dispatch would silently get no close button.
Both keys are now supported with a fallback chain — fully backward-compatible:
const showCloseBtn = detail?.options?.showCloseBtn ?? detail?.options?.closeButton ?? false;
str_replace('\n', ...) — single-quoted '\n' in PHP is a literal backslash-n, never a newline. The line was unreachable and has been removed.use Exception; import from ToastMagic.php.showDuration and timeOut in config/laravel-toaster-magic.php were stored as strings ("300", "5000"). They are now proper integers (300, 5000).closeButton and showCloseBtn integrations continue to workcomposer update devrabiul/laravel-toaster-magic
Then re-publish assets:
php artisan vendor:publish --tag=laravel-toaster-magic-assets --force
Assets are also auto-published on the next page load via the built-in version-diffing mechanism.
Laravel Toaster Magic is designed to be the only toaster package you'll need for any type of Laravel project. Whether you are building a corporate dashboard, a modern SaaS, a gaming platform, or a simple blog, I have crafted a theme that fits perfectly.
"One Package, Many Themes." — No need to switch libraries just to change the look.
This major release brings 7 stunning new themes, full Livewire v3/v4 support, and modern UI enhancements.
I have completely redesigned the visual experience. You can now switch between 7 distinct themes by simply updating your config.
| Theme | Config Value | Description |
|---|---|---|
| Default | 'default' |
Clean, professional, and perfect for corporate apps. |
| Material | 'material' |
Google Material Design inspired. Flat and bold. |
| iOS | 'ios' |
(Fan Favorite) Apple-style notifications with backdrop blur and smooth bounce animations. |
| Glassmorphism | 'glassmorphism' |
Trendy frosted glass effect with vibrant borders and semi-transparent backgrounds. |
| Neon | 'neon' |
(Dark Mode Best) Cyberpunk-inspired with glowing neon borders and dark gradients. |
| Minimal | 'minimal' |
Ultra-clean, distraction-free design with simple left-border accents. |
| Neumorphism | 'neumorphism' |
Soft UI design with 3D embossed/debossed plastic-like shadows. |
👉 How to use:
// config/laravel-toaster-magic.php
'theme' => 'neon',
I've rewritten the Javascript core to support Livewire v3 & v4 natively.
Livewire.on (v3) or standard event dispatching.wire:navigate.// Dispatch from component
$this->dispatch('toastMagic',
status: 'success',
message: 'User Saved!',
title: 'Great Job'
);
Want your toasts to pop without changing the entire theme? Enable Gradient Mode to add a subtle "glow-from-within" gradient based on the toast type (Success, Error, etc.).
// config/laravel-toaster-magic.php
'gradient_enable' => true
Works best with Default, Material, Neon, and Glassmorphism themes.
Don't want themes? Just want solid colors? Color Mode forces the background of the toast to match its type (Green for Success, Red for Error, etc.), overriding theme backgrounds for high-visibility alerts.
// config/laravel-toaster-magic.php
'color_mode' => true
I have completely modularized the CSS.
.theme-neon, .theme-ios) to prevent conflicts.body[theme="dark"].Upgrading from v1.x to v2.0?
Update Composer:
composer require devrabiul/laravel-toaster-magic "^2.0"
Check Config: If you have a published config file, add the new options:
'options' => [
'theme' => 'default',
'gradient_enable' => false,
'color_mode' => false,
],
'livewire_version' => 'v3',
v2.0 transforms Laravel Toaster Magic from a simple notification library into a UI-first experience. Whether you're building a sleek SaaS (use iOS), a gaming platform (use Neon), or an admin dashboard (use Material), there is likely a theme for you.
Enjoy the magic! 🍞✨
JavaScript Stability Fixes: Resolved multiple JS-related issues that could cause inconsistent toast behavior in SPA and dynamic page loads. Toasts now render more reliably across Livewire, Alpine.js, and AJAX-driven views.
Improved Event Handling: Fixed edge cases where custom events were not always triggering toast notifications. Event listeners are now more predictable and better scoped.
DOM Ready & SPA Support: Enhanced initialization logic to ensure Toaster Magic works smoothly with page transitions, including Turbo, Inertia, and Livewire navigation.
Performance Tweaks: Reduced unnecessary DOM queries and optimized JS execution flow for faster toast rendering with lower overhead.
Backward Compatibility: Fully compatible with v1.5 and earlier versions — no breaking changes. Existing integrations continue to work without modification.
Documentation Updates: Updated frontend usage examples to reflect the improved JS behavior and best practices.
Version 1.6 focuses on frontend reliability and smoother user experience. With important JavaScript fixes and performance improvements, Toaster Magic now delivers more consistent notifications across modern, dynamic Laravel applications.
Exception Fallback Handling: Added robust exception handling across all toast operations. Now, unexpected errors are gracefully managed without breaking your application. Developers can also provide custom handlers via configuration.
Performance & Optimization: Optimized core toast logic for faster execution. Minified assets and reduced runtime overhead to make the package leaner and more efficient.
PHP & Laravel Compatibility: Fully compatible with PHP 8.0 → 8.4 and Laravel 8 → 12. This ensures smooth integration across modern Laravel projects.
Backward Compatibility: Upgrading from v1.x is seamless. All previous configurations and usages remain supported.
Documentation & Examples: Updated usage examples and configuration instructions for easier integration.
All other configurations remain backward-compatible.
This release focuses on stability, performance, and developer experience. With v1.5, Laravel Toaster Magic is more robust, optimized, and ready for modern Laravel projects.
This release brings exciting visual improvements with Gradient Effects, fixes for Color Mode, and reorganizes the asset directory structure for better maintainability and package publishing.
🌈 New Feature: Gradient Effects
gradient_enable in the config to add smooth gradient backgrounds to all toast notifications.🎨 Fixed Color Mode
color_mode did not apply the correct colors for some toast types (success, error, warning, info).📂 Asset Directory Updates
artisan vendor:publish workflow.🧹 Other Improvements
composer update devrabiul/laravel-toaster-magic
php artisan config:clear
// config/laravel-toaster-magic.php
return [
'options' => [
'gradient_enable' => true,
'color_mode' => true,
// other options...
],
'livewire_enabled' => true,
'livewire_version' => 'v3',
];
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Thanks to all contributors and community members for helping! ❤️
Happy Toasting! 🍞✨
This release introduces a new Color Mode feature that automatically applies toast colors based on toast types, along with important fixes for SPA navigation issues to improve Livewire and frontend routing compatibility.
🎨 New Feature: Color Mode
color_mode in the config to automatically apply distinct colors for toast types (success, error, warning, info).🛠️ Fixed SPA Navigation Issues
🧹 Other Improvements
composer update devrabiul/laravel-toaster-magic
php artisan config:clear
// config/laravel-toaster-magic.php
return [
'options' => [
// other options...
'color_mode' => true,
],
'livewire_enabled' => true,
'livewire_version' => 'v3',
];
Thanks to all community members who helped identify SPA navigation issues and supported the color mode feature development! ❤️
Happy Toasting! 🍞✨
This release focuses on fixing the positionClass config issue and includes other small improvements to enhance your experience with Laravel Toaster Magic.
positionClass
The default positionClass in config/laravel-toaster-magic.php is now correctly set to:'positionClass' => 'toast-bottom-start',
If you’ve not published the config, run:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
✨ Improved Option Merging Logic
Custom options from your config() and runtime calls now merge more reliably.
🧹 Minor Cleanup Small internal cleanups for better code quality.
composer update devrabiul/laravel-toaster-magic
Or,
composer update
php artisan config:clear
Big thanks to [@redredimano](https://github.com/redredimano) for reporting the config issue! ❤️
Happy Toasting! 🍞✨ https://github.com/devrabiul/laravel-toaster-magic
I'm excited to announce v1.1 of Laravel Toaster Magic — a smooth and powerful toast notification package for Laravel and Livewire.
🔥 Material Design Theme
✅ Auto Asset Update Issue Fixed
✅ Livewire JavaScript Compatibility Fixed
wire:navigate and Livewire.on() events.Run:
composer update devrabiul/laravel-toaster-magic
(Optional) Re-publish the assets to get the new Material theme:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Thank you for using Laravel Toaster Magic! ⭐️ Star the repo if you find it useful. Contributions and feedback are always welcome!
Custom Button Support in Livewire Toasts:
You can now include custom buttons in your Livewire-dispatched toasts. Add a link with custom text directly inside the toast notification using the options parameter:
$this->dispatch('toastMagic',
status: 'success',
title: 'User Created',
message: 'The user has been successfully created.',
options: [
'showCloseBtn' => true,
'customBtnText' => 'Link Text',
'customBtnLink' => 'https://demo.com',
],
);
Improved Option Handling: The toast system now gracefully parses and applies advanced configuration options passed from Livewire, offering more control and flexibility.
Better UX with Optional Close Button:
Developers can now toggle a close button per toast using showCloseBtn, offering users manual dismissal options.
Refined Event Handling:
Fine-tuned the way toastMagic events are handled to improve reliability and compatibility across Livewire’s lifecycle events.
Livewire Script Path Issues Resolved: Fixed loading problems with Livewire v3 JavaScript assets to ensure correct path resolution and smooth integration.
Robust Fallbacks for Livewire Scripts: Improved fallback logic for loading core toaster scripts when Livewire assets are unavailable, preventing broken toast notifications.
Full Livewire v3 Support Added:
Seamless integration with Livewire v3 via $this->dispatch('toastMagic', ...) for easy toast notifications directly from Livewire components.
Configurable Livewire Settings:
New configuration options 'livewire_enabled' => true and 'livewire_version' => 'v3' allow developers to toggle and specify Livewire versions with ease.
Enhanced Developer Experience for Livewire Users: Improved asset loading and event dispatching designed to work flawlessly with Livewire’s lifecycle and script management.
A powerful and flexible Toaster package for Laravel applications, designed to enhance user experience with customizable toast notifications.
How can I help you explore Laravel packages today?