If you find PHPFlasher useful, we would greatly appreciate your support in the form of a star rating ⭐ on GitHub or by sharing the project on Twitter click here. Your feedback helps us keep the package up-to-date and well-maintained. Thank you
Let’s say you have a custom notification that you want to use in multiple places. You can create a preset for it and then use it in multiple places.
You can think of a preset as a pre-defined message that you can use in multiple places.
For Laravel:
// config/flasher.php
return [
'default' => 'flasher',
'presets' => [
'entity_saved' => [
'type' => 'success',
'message' => 'Entity saved successfully',
'title' => 'Entity saved',
],
],
];
For Symfony:
# config/packages/flasher.yaml
flasher:
default: theme.bootstrap
presets:
entity_saved:
type: success
message: Entity saved successfully
title: Entity saved
And then use it in your controller:
class BookController
{
public function save(FlasherInterface $flasher)
{
$flasher->addPreset('entity_saved')