PHP code example of pentiminax / ux-sweet-alert

1. Go to this page and download the library: Download pentiminax/ux-sweet-alert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pentiminax / ux-sweet-alert example snippets


use Pentiminax\UX\SweetAlert\AlertManagerInterface;

#[Route('/', name: 'app_homepage')]
public function index(AlertManagerInterface $alertManager): Response
{
    $alertManager->success(
        title: 'Update Successful',
        text: 'Your settings have been saved.'
    );

    return $this->redirectToRoute('dashboard');
}

use Pentiminax\UX\SweetAlert\Enum\Position;
use Pentiminax\UX\SweetAlert\ToastManagerInterface;

class HomeController extends AbstractController
{
    #[Route('/', name: 'app_homepage')]
    public function index(ToastManagerInterface $toastManager): Response
    {
       $toastManager->success(
            title: 'title',
            text: 'text',
            position: Position::TOP_END,
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true
        );

        return $this->render('home/index.html.twig');
    }
}