Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Flasher Sweetalert Laravel

Flasher Sweetalert Laravel Laravel Package

php-flasher/flasher-sweetalert-laravel

View on GitHub
Deep Wiki
Context7

[READ-ONLY] Laravel integration for Flasher SweetAlert, providing eye-catching notification messages in Laravel projects using SweetAlert2.

Frequently asked questions about Flasher Sweetalert Laravel
How do I install php-flasher/flasher-sweetalert-laravel in a Laravel project?
Run `composer require php-flasher/flasher-sweetalert-laravel` and register the service provider in `config/app.php` under the `providers` array. No additional backend setup is needed if you’re already using Laravel’s native flash messages.
Does this package work with Laravel 10+? What’s the minimum supported version?
The package supports Laravel 8.x and above, including Laravel 10. Check the [official docs](https://php-flasher.io) for version-specific compatibility notes, as newer Laravel releases may require minor adjustments for session handling.
Can I customize SweetAlert2’s appearance (colors, icons, animations) without touching JavaScript?
Yes, use the package’s config file (`config/flasher.php`) to define default icons, colors, and timing for different message types (e.g., success, error). For advanced styling, override the SweetAlert2 CSS variables or extend the package’s JavaScript.
Will this conflict with existing Bootstrap modals or other UI libraries?
SweetAlert2 is modal-based, so conflicts may arise if your app uses overlapping modal systems. Mitigate this by scoping SweetAlert’s CSS classes (e.g., `.swal2`) or using Laravel Mix/Vite to isolate dependencies. Test in staging first.
How do I use flash messages in API routes or non-Blade responses?
Flash messages are session-based and require Blade directives (`@flasher`) to render. For APIs, use HTTP status codes or return JSON responses with error/success messages. If you need SweetAlert in SPAs, consider polling the backend for flash data.
Is there a way to auto-dismiss flash messages after a delay?
Yes, configure the `autoDismiss` option in `config/flasher.php` with a timeout in milliseconds (e.g., `5000` for 5 seconds). You can also customize this per message type or dynamically via JavaScript.
Does this package support real-time updates (e.g., WebSocket or Livewire) for flash messages?
No, flash messages rely on Laravel’s session storage, which is request-bound. For real-time apps, manually push flash data via WebSocket events or use client-side storage (e.g., localStorage) to sync messages across page reloads.
How do I test flash messages in PHPUnit or Pest?
Mock the session driver to simulate flash messages. For example, use `Session::shouldReceive('flash')->andReturn('test')` in PHPUnit. Test SweetAlert rendering with browser automation tools like Laravel Dusk or Playwright.
What session drivers are supported, and how do I configure them?
The package works with Laravel’s default session drivers (file, database, Redis, etc.). No extra configuration is needed unless you’re using a custom driver. Ensure your session middleware is properly registered in `app/Http/Kernel.php`.
Are there alternatives to this package for SweetAlert2 flash messages in Laravel?
Yes, consider `spatie/laravel-flash` (for basic flashes) or `torann/laravel-notification-channels-sweetalert` (for notification channels). However, this package uniquely combines SweetAlert2 with Laravel’s native flash system for a seamless, modal-based UX.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity