Download the PHP package drewpereli/flasher without Composer
On this page you can find all versions of the php package drewpereli/flasher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drewpereli/flasher
More information about drewpereli/flasher
Files in drewpereli/flasher
Package flasher
Short Description Flash messages for php
License MIT
Homepage https://github.com/drewpereli/flasher
Informations about the package flasher
Flasher
This is a very small package that makes it easy to implement flash message.
Installation
Install with composer.
composer require drewpereli/flasher
Or download the source from github.
Usage
Flasher is super easy to use! On any php file you'd like to use flahser in, include it by requiring the composer autoloader.
If you're not using composer, simply include or require the file "flasher.php" in any file that uses the flasher.
To set and get flash messages, create a new flasher object.
You can create a new flasher object at the top of each file that needs the flasher. The new object will have access to any flash messages set by any other existing or previous flasher object.
Set messages like this:
Get messages like this:
As soon as you "get" a message, it will be removed.
You can also use magic methods!
Full method list
- set(type, message): Sets message of "type" to "message".
- get(type): Returns and unsets the message of "type".
- getAll(): Returns an array of all messages, indexed by type. Unsets all messages.
- peek(type): Returns the message of "type" without unsetting it.
- flash(type): Equivalent to "echo get(type);".
- has(type): Returns true if a message of "type" has been set. Otherwise returns false.
- hasAny(): Returns true if a flash message of any type is currently set. Otherwise returns false.