Download the PHP package mercuryseries/flashy-bundle without Composer
On this page you can find all versions of the php package mercuryseries/flashy-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mercuryseries/flashy-bundle
More information about mercuryseries/flashy-bundle
Files in mercuryseries/flashy-bundle
Package flashy-bundle
Short Description Easy flash notifications in Symfony
License MIT
Informations about the package flashy-bundle
Nice Flash Messages in Symfony
Copyright
Inspired by Jeffrey Way's Flash Package.
Installation
Video Tutorial
https://www.youtube.com/watch?v=sxLceVKcWoc
You like text ?
- First, use Composer to download the library:
-
For Symfony 5.3+:
composer require mercuryseries/flashy-bundle
- For Symfony versions lower than 5.3, please use:
composer require "mercuryseries/flashy-bundle:^3.0"
- Then add the MercurySeriesFlashyBundle to your application:
In Symfony < 4:
In Symfony 4 with Symfony Flex this will be done automatically for you.
Usage
Once the bundle is installed, you can autowire a FlashyNotifier
into any controller:
You may also do:
$flashy->info('Welcome Aboard', 'http://your-awesome-link.com')
$flashy->success('Welcome Aboard', 'http://your-awesome-link.com')
$flashy->error('Uh Oh', 'http://your-awesome-link.com')
$flashy->warning('Be careful!', 'http://your-awesome-link.com')
$flashy->primary('Thanks for signing up!', 'http://your-awesome-link.com')
$flashy->primaryDark('Thanks for signing up!', 'http://your-awesome-link.com')
$flashy->muted('Can you see me?', 'http://your-awesome-link.com')
$flashy->mutedDark('Can you see me?', 'http://your-awesome-link.com')
This will set a few keys in the session:
- 'mercuryseries_flashy_notification.message' - The message you're flashing
- 'mercuryseries_flashy_notification.type' - A string that represents the type of notification (good for applying HTML class names)
- 'mercuryseries_flashy_notification.link' - The URL to redirect to on click
With this message flashed to the session, you may now display it in your view(s) by including the partial @MercurySeriesFlashy/flashy.html.twig
:
Example
Note that this bundle has jQuery as dependency. It's also better to load the flashy partial before your body close tag.
If you need to modify the default flash message partial, you can create a bundles/MercurySeriesFlashyBundle/flashy.html.twig
in your templates
folder.
The default content of @MercurySeriesFlashy/flashy.html.twig
is:
Basic CSS & JS for the default partial
The bundles comes with basic CSS & JS for the default partial so you can get started faster. Of course you can change them, use another ones or create your own partial.
Again, note that this bundle has jQuery as dependency.
Nice rendering
For a nice rendering you may include these lines in your head:
and override the following sections of the default flashy view:
Configuration
All versions of flashy-bundle with dependencies
symfony/config Version ^4.4 || ^5.3 || ^6.0
symfony/dependency-injection Version ^4.4 || ^5.3 || ^6.0
symfony/http-kernel Version ^4.4 || ^5.3 || ^6.0