Flash notifications
, (*1)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)
$ composer require lexty/flashybundle "dev-master"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:, (*4)
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Lexty\FlashyBundle\LextyFlashyBundle(), ); // ... } // ... }
Call the function lexty_flashy_render()
in template:, (*5)
<body> ... {{ lexty_flashy_render()|raw }} ... </body>
// src/AppBundle/Controller/DefaultController.php public function indexAction() { $flashy = $this->container->get('lexty_flashy'); $flashy->add('Test message!', Flashy::TYPE_SUCCESS); // ... }
flashy.add('Success message!', 'success');
Flashy::TYPE_INFO
(info
)Flashy::TYPE_SUCCESS
(success
)Flashy::TYPE_WARNING
(warning
)Flashy::TYPE_ERROR
(error
)Flashy::TYPE_MUTED
(muted
)Flashy::TYPE_MUTED_DARK
(muted-dark
)Flashy::TYPE_PRIMARY
(primary
)Flashy::TYPE_PRIMARY_DARK
(primary-dark
)# config/config.yml lexty_flashy: delay: 2800 # while displaying flash messages (in milliseconds)
MIT, (*6)