Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikkez/f3-flash
Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework
https://github.com/ikkez/f3-flash
fat-free-framework flash flash-messages
Last synced: 20 days ago
JSON representation
Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework
- Host: GitHub
- URL: https://github.com/ikkez/f3-flash
- Owner: ikkez
- License: gpl-3.0
- Created: 2017-02-17T13:20:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-16T20:30:30.000Z (over 3 years ago)
- Last Synced: 2024-11-07T10:18:41.210Z (about 2 months ago)
- Topics: fat-free-framework, flash, flash-messages
- Language: PHP
- Size: 15.6 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flash
This is a little plugin to add simple Flash Messages and Flash Keys for PHP Fat-Free-Framework, version 3.x
### Installation
- Method 1: use composer composer require ikkez/f3-flash
- Method 2: copy the `flash.php` file into your F3 `lib/` directory or another directory that is known to the [AUTOLOADER](https://fatfreeframework.com/quick-reference#AUTOLOAD)
### Usage
To add a message (or multiple) that should only be displayed once in your template on the next request, just do:
```php
\Flash::instance()->addMessage('You did that wrong.', 'danger');
// or
\Flash::instance()->addMessage('It worked!', 'success');
```And to display that in your templates do:
```html
×
{{ @msg.text | esc }}```
That's it.
If you need, you could also add simple keys:
```php
$flash = \Flash::instance()
$f3->set('FLASH', $flash);
$flash->setKey('highlight','bg-success'); // with value
$flash->setKey('show-hint'); // without returns just TRUE
$flash->setKey('error','Catastrophic error occured! ');
```for use cases like:
```html
It's new !!!
...
``````html
{{ @FLASH->getKey('error') }}
```
## License
You are allowed to use this plugin under the terms of the GNU General Public License version 3 or later.
Copyright (C) 2017 Christian Knuth [ikkez]