Installation
Install the bundle
Add the package
composer require pentiminax/ux-sweet-alert
Make sure the frontend controller can run
Render the Twig helper
Add the helper to the base layout that should display alerts and toasts:
<head>
{{ ux_sweet_alert_scripts() }}
</head>
Minimal verification
Create a controller action that queues a toast or alert, then redirects to a rendered page:
use Pentiminax\UX\SweetAlert\AlertManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class DashboardController extends AbstractController
{
#[Route('/dashboard', name: 'app_dashboard')]
public function __invoke(AlertManagerInterface $alertManager): Response
{
$alertManager->success(
title: 'Installed',
text: 'UX SweetAlert is ready to render.'
);
return $this->render('dashboard/index.html.twig');
}
}
If the helper is mounted correctly, the success modal appears when the page renders.
What to read next
- Quick Start for the smallest working example.
- Configuration for defaults and flash conversion.
- Themes & Styling for SweetAlert2 theme assets.