Symfony bundle integrating PHPFlasher into Symfony applications

Fund package maintenance!

Installs: 1 180 802

Dependents: 11

Suggesters: 0

Security: 0

Stars: 9

Watchers: 2

Forks: 1


v1.8.1 2022-11-21 20:31 UTC


PHPFlasher Logo

Flexible flash notifications system for Symfony

Official Documentation

Documentation for PHPFlasher can be found on the PHPFlasher website.


PHPFlasher offers a solid integration with the Symfony framework, with supports from Symfony 2.0 to 6.


You can install the PHPFlasher Symfony bundle using composer. This is the base package for all Symfony adapters (toastr, sweetalert, notyf ..etc).

composer require php-flasher/flasher-symfony

If you are using Symfony version 4+ the bundle will be registered automatically in config/bundles.php, otherwise enable the bundle in the kernel:

public function registerBundles()
    $bundles = [
        // ...
        new Flasher\Symfony\FlasherSymfonyBundle(),
        // ...


The usage of this bundle is very simple and straightforward. it only required one step to use it and does not require anything to be included in your views:

Use FlasherInterface service inside your controller to set a toast notification for info, success, warning or error


namespace App\Controller;

use Flasher\Prime\FlasherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

class BookController extends AbstractController
    public function save(FlasherInterface $flasher): Response
        // ...

        $flasher->addSuccess('Book saved successfully');

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

Basic api methods:

  • flash()->addSuccess('Data has been saved successfully!')
  • flash()->addError('Oops! An error has occurred.')
  • flash()->addWarning('Are you sure you want to delete this item?')
  • flash()->addInfo('Welcome to the site!')

By default PHPFlasher show its default notification style. To use another adapter, use the create() method or its Factory service :

class PostController
   public function create(FlasherInterface $flasher): Response
         ->error('An error has occurred, please try again later.')

   public function edit(FlasherInterface $flasher): Response
      $toastr = $flasher->create('toastr'); // You need to require php-flasher/flasher-toastr-symfony
      $toastr->addSuccess('This notification will be rendered using the toastr adapter');

   public function update(ToastrFactory $toastr): Response
         ->warning('Something went wrong!')


PHPFlasher is being actively developed by yoeunes. You can reach out with questions, bug reports, or feature requests on any of the following:


PHPFlasher is open-sourced software licensed under the MIT license.

Made with ❤️ by Younes KHOUBZA