1. Go to this page and download the library: Download php-notify/notify-symfony 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/ */
php-notify / notify-symfony example snippets
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
class BookController extends AbstractController
{
public function saveBook(): RedirectResponse
{
// Your logic here
flash('Your changes have been saved!');
return $this->redirectToRoute('book_list');
}
}
namespace App\Controller;
use Flasher\Prime\FlasherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
class AnotherController extends AbstractController
{
private FlasherInterface $flasher;
public function __construct(FlasherInterface $flasher)
{
$this->flasher = $flasher;
}
public function register(): RedirectResponse
{
// Your logic here
$this->flasher->success('Your changes have been saved!');
// ... redirect or render the view
return $this->redirectToRoute('home');
}
public function update(): RedirectResponse
{
// Your logic here
$this->flasher->error('An error occurred while updating.');
return $this->redirectToRoute('update_page');
}
}
flash()->info('This is an informational message.');
flash()->warning('This is a warning message.');
flash()->success('Custom message with options.', ['timeout' => 3000, 'position' => 'bottom-left']);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
class BookController extends AbstractController
{
public function save(): RedirectResponse
{
// Your saving logic
flash()->preset('entity_saved');
return $this->redirectToRoute('books.index');
}
public function delete(): RedirectResponse
{
// Your deletion logic
flash()->preset('entity_deleted');
return $this->redirectToRoute('books.index');
}
}
bash
composer
shell
php bin/console flasher:install
bash
php bin/console flasher:install --config
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.