定制 berlioz/flash-bag 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

berlioz/flash-bag

最新稳定版本:v1.3.0

Composer 安装命令:

composer require berlioz/flash-bag

包简介

Berlioz FlashBag is a PHP library to manage flash messages to showed to the user.

README 文档

README

Latest Version Software license Build Status Quality Grade Total Downloads

Berlioz FlashBag is a PHP library to manage flash messages to showed to the user.

Installation

Composer

You can install Berlioz FlashBag with Composer, it's the recommended installation.

$ 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.

Add message

It's very simple to add messages:

$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:

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:

$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:

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

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

统计信息

  • 总下载量: 8.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-24