2017 © Pedro Peláez
 

library flash-bag

Berlioz Flash Bag Messages

image

berlioz/flash-bag

Berlioz Flash Bag Messages

  • Friday, June 29, 2018
  • by ElGigi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 467 % Grown

The README.md

Berlioz FlashBag

Latest Version Software license Build Status Quality Grade Total Downloads, (*1)

Berlioz FlashBag is a PHP library to manage flash messages to showed to the user., (*2)

Installation

Composer

You can install Berlioz FlashBag with Composer, it's the recommended installation., (*3)

$ composer require berlioz/flash-bag

Dependencies

  • PHP ^7.1 || ^8.0

Usage

All messages are stored in session of user. So you be able to get the messages after a reload of page or redirect. When you got the messages, they are deleted on the stack and no longer available., (*4)

Add message

It's very simple to add messages:, (*5)

$flashBag = new FlashBag;
$flashBag
    ->add(FlashBag::TYPE_SUCCESS, 'Message success')
    ->add(FlashBag::TYPE_INFO, 'Second message')
    ->add(FlashBag::TYPE_INFO, 'Third message for %d %s', 3, 'persons');

Some default types are available in constants:, (*6)

FlashBag::TYPE_INFO = 'info';
FlashBag::TYPE_SUCCESS = 'success';
FlashBag::TYPE_WARNING = 'warning';
FlashBag::TYPE_ERROR = 'error';

Get message

To get message, it's also simple then add:, (*7)

$flashBag = new FlashBag;
$successMessages = $flashBag->get('success');

foreach ($successMessages as $msg) {
    print $msg;
}

Get all messages

You can also get all messages in one time:, (*8)

$flashBag = new FlashBag;
$allMessages = $flashBag->all();

foreach ($allMessages as $type => $messages) {
    foreach ($messages as $msg) {
        print sprintf('%s: %s', $type, $msg);
    }
}

The Versions

29/06 2018

dev-master

9999999-dev http://www.berlioz-framework.com

Berlioz Flash Bag Messages

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ronan Giron

29/06 2018

v1.0.0

1.0.0.0 http://www.berlioz-framework.com

Berlioz Flash Bag Messages

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ronan Giron

29/06 2018

dev-develop

dev-develop http://www.berlioz-framework.com

Berlioz Flash Bag Messages

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ronan Giron