mislant / flash
Helper for flash messages for users
1.0.0
2021-05-18 05:45 UTC
Requires
- php: 8.*
- myclabs/php-enum: ^1.8
This package is auto-updated.
Last update: 2025-03-18 15:01:23 UTC
README
Flash messages helper.
Flash is a library designed to unify the interface for working with flash messages. It provides functionality for creating and receiving messages. Flash does not restrict the user in the implementation of this functionality, as well as the choice of storage for messages.
To begin work with Flash create flash generator. You can use base implementation class FlashGenerator
public function someAction() { # here is some business logic $flashGenerator = new FlashGenerator( SetterInterface::class # your storage setter implementation ); # end of business logic if ($businessResult) { $flashGenerator->success('Everything is Ok'); return $businessResult; } $flashGenerator->error('Something goes wrong'); return $businessResult; }
To get flashes use flash getter. You can also use base implementation class FlashExtractor
public function showAlerts() { $flashExtractor = new FlashExtractor( GetterInterface::class # your getter from storage implementation ); # Your render logic $messages = $flashExtractor->info(); foreach ($messages as $message){ showAlert($message); } }