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\AlertManagerInterface;
use Pentiminax\UX\SweetAlert\Enum\Position;

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

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

use Pentiminax\UX\SweetAlert\AlertManagerInterface;
use Pentiminax\UX\SweetAlert\InputType\Text;

#[Route('/profile', name: 'app_profile')]
public function index(AlertManagerInterface $alertManager): Response
{
    $alertManager->input(
        inputType: new Text(
            label: 'Display name',
            value: 'Tanguy',
            placeholder: 'Enter your display name',
        ),
        title: 'Update profile',
        text: 'This change is visible to other users.'
    );

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