PHP code example of marilenarm / turbo-toast-bundle
1. Go to this page and download the library: Download marilenarm/turbo-toast-bundle 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/ */
use MarilenaRM\TurboToastBundle\Controller\TurboToastTrait;
final class ItemController extends AbstractController
{
use TurboToastTrait;
#[Route('/items', methods: ['POST'])]
public function create(Request $request): Response
{
// ... persist
return $this->toast('Item saved');
// or: $this->toast('Oops', 'error');
// or: $this->toast('Coming soon', 'info', delay: 8000);
}
}
use MarilenaRM\TurboToastBundle\Toast\Toast;
return $this->toasts(
new Toast('Profile updated'),
new Toast('A confirmation email has been sent', 'info'),
);
#[Route('/login', methods: ['POST'])]
public function login(): Response
{
// ... authenticate
$this->deferToast('Welcome back!');
return $this->redirectToRoute('dashboard');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.