承接 stagem/zfc-flash 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

stagem/zfc-flash

Composer 安装命令:

composer require stagem/zfc-flash

包简介

ZF Adapters for different Flash Managers

README 文档

README

ZF Adapters for different Flash Managers

There are many FLash Messages implementation and all of them have different interfaces. This plugin provide one FlashInterface which allow write custom Adapter for any Flash library.

By default this package uses slim/flash.

Package has several registered namespace which allow group massages and show beauty html markup for all of them.

  • default
  • success
  • warning
  • error
  • info

Installation

composer require stagem/zfc-flash

In Expressive

You should enable module in config/config.php as Stagem\ZfcFlash\ConfigProvider::class and register middleware inconfig/pipeline.php

$app->pipe(\Stagem\ZfcFlash\FlashMiddleware::class);

This allow gets flash object from request as $flash = $request->getAttribute('flash');

Usage

In Expressive

use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response\RedirectResponse;

function($request, RequestHandlerInterface $handler)
{
    $flash = $request->getAttribute('flash');
    $flash->addMessage('Hello World!', 'success');

    return new RedirectResponse('/other-middleware');
}

Out of the box this module works with Zend\View\Helper\FlashMessenger and twitter bootstrap

Include flash-messages template in your template as <?= $this->partial('widget::flash-messages') ?>

If you want change html markup or style see section Custom Flash.

Custom Flash

Be carefully, you should enable your module after Stagem\ZfcFlash\ConfigProvider::class in config/config.php

You can develop custom adapter for any Flash Messages only implement Stagem\ZfcFlash\FlashInterface and register in depenencies in your config/module.config.php

Custom template

Create new .phtml file, get messages and implement custom html markup. You can use current helper or other approach for get Request object and than get the flash.

// view/widget/flash-messages.phtml
#$flash = $this->current('request')->getAttribute('flash');
$messages = $flash->getAllMessages();
// iterate over array 

After that add your template to config/module.config.php and include in template

return [
    'templates' => [
        'paths' => [
            'widget' => [__DIR__ . '/../view/widget'],
        ],
    ],
];

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固