krubio / perfect-flash
Session Based Flash Messaging - Bootstrap 5
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:HTML
Requires
- php: >=8.0.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-28 20:19:45 UTC
README
Code Coverage Reports
Dashboard
Overview
Detailed Report
FlashMessage Usage Guide:
The FlashMessage class is a convenient way to display messages to your users. It is initialized with a config array that contains messages for different types of actions. To use it, follow these steps:
(Assumes you have started a session)
Import the FlashMessage class into your code:
use PerfectApp\Flash\FlashMessage;
Create an instance of the FlashMessage class, passing the config array to its constructor:
$config = [ 'success' => [ 'create' => 'Item created successfully!', 'update' => 'Item updated successfully!' ], 'danger' => [ 'create' => 'Failed to create item.', 'update' => 'Failed to update item.' ] ]; $flash = new FlashMessage($config);
To display a message, call the set()
method on the $flash
object. Pass the type of message ('success', 'danger', etc.), the action performed ('create', 'update', etc.), and optionally an icon to display with the message. Icons require Bootstrap 5:
$flash->set('success', 'create', '<i class="bi bi-check-circle-fill"></i>');
To display all messages, call the display()
method on the $flash
object:
$flash->display();
That's it! You can call set()
and display()
methods as many times as you need to display different messages to your users. The messages will be displayed in the order they were added, and will automatically be cleared after they are displayed.