Download the PHP package rasmusgodske/flashbeep without Composer
On this page you can find all versions of the php package rasmusgodske/flashbeep. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package flashbeep
FlashBeep
FlashBeep is a flexible flash messaging system for Laravel applications. It allows easy integration and customization of flash messages across your application, supporting dynamic instantiation, named parameters, and predefined message types.
FlashBeep makes it easy to create flash messages using the flashMessage helper function. The function takes a message object and stores it in the session for display in your views.
Features
- Dynamic Message Creation: Create flash messages on-the-fly using named or positional parameters.
- Configurable: Define and customize flash message types via configuration.
- Extendable: Easily extend with custom message types.
Installation
Use Composer to install FlashBeep into your PHP project:
Configuration
After installing the package, comes with a default configuration file. You can publish the configuration file using the following command:
Edit the config/flash_messages.php to set up your message types and session keys:
To add a custom message type see the Creating Custom Message Types section.
Usage
You can use the flashMessage function to create and flash a message instantly.
Here are some examples of how you can create and flash messages in your controllers:
Displaying Messages
To display the flashed messages in your views, you can use the getFlashMessages().
getFlashMessages() simply returns an array of FlashMessageInterface objects. As seen here:
Using with Laravel Blade
Here is an example of how you can display the flashed messages in a Laravel Blade view:
[!CAUTION] This has not been tested yet.
Using with InertiaJS
Here is an example of how you can pass the flash messages to inertia using the HandleInertiaRequests Middleware.
Creating Custom Message Types
The easiest way to create a custom message type is to extend the AbstractFlashMessage class and add your your attributes using $this->setAttribute('key', 'value'). Here is an example of a custom message type:
To make your FlashMessage available to use with the flashMessage function, you need to add it to the config/flash_messages.php file:
Now you can use your custom message type like this:
Or without adding it to the configuration file:
All versions of flashbeep with dependencies
laravel/framework Version ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0