fungku / sweet-flasher
Sweet flash messaging
v0.1
2015-08-26 02:23 UTC
Requires
- php: >= 5.5
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-11-09 18:54:05 UTC
README
Simple, sweet flash messages.
Currently supports Laravel and (maybe) Symfony.
Install
Install with composer like any sane developer.
Composer
composer require "fungku/sweet-flasher: ~0.1@dev"
Laravel
For Laravel apps, add the Service Provider class to config/app.php
services array:
Fungku\SweetFlasher\Providers\SweetFlasherLaravelServiceProvider::class,
Symfony
For Symfony, try the SymfonySessionFlasher
.
I don't actually know how Symfony works, I was just trying to provide an example.
If you do know, please help me out here.
Usage
Laravel:
Inject it
use Fungku\SweetFlasher\FlashMessage; class MyController extends Controller { public function store(FlashMessage $flashMessage) { // save ... $flashMessage->success("Nicely done"); return response(); } }
Or if you are a lazy piece of crap use the helper function flash()
:
// Default info message flash("This is a default info message"); // Other usages like: // flash->{$level}($message, $title, $confirm_button_text) flash()->success("This is a success message"); flash()->error("Some error!"); flash()->warning("Some Warning!", "Uh oh!");
Symfony (maybe):
use Fungku\SweetFlasher\FlashMessage; class MyController { private $flash; public function __construct(FlashMessage $flash) { $this->flash = $flash; } public function doAction() { // .. do action $this->flash->success('You did it!'); } }
Everybody else:
You can do it.
Notes
This is nearly a fork of laracasts/flash