dotkernel/dot-flashmessenger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dotkernel/dot-flashmessenger

最新稳定版本:3.7.0

Composer 安装命令:

composer require dotkernel/dot-flashmessenger

包简介

Dotkernel flash messenger component for session messages between redirects

README 文档

README

Flash messenger library for session messages between redirects. A flash message, or session message is a piece of text data that survives one request (available only in the next request). This library accepts session data as well, not just string messages, with the same behavior. The flash messenger is a convenient way to add data to the session and get it back on the next request without bothering with setting and clearing the data manually.

Documentation

Documentation is available at: https://docs.dotkernel.org/dot-flashmessenger/.

Badges

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static codecov PHPStan

Installation

Run the following command in your project folder

composer require dotkernel/dot-flashmessenger

This will also install laminas/laminas-session as session handling is based on this library. Next, merge the ConfigProvider to your application's configuration.

Configuration

return [ 'dot_flashmessenger' => [ 'namespace' => 'flash messages session namespace name' ], ];

Sets the session namespace to be used for all flash messages and data.

Usage

If following the installation step, you'll already have a FlashMessenger service in the service manager. Inject this service in your classes, wherever you need flash messages.

Getting the service in a factory

$container->get(FlashMessengerInterface::class);

Using the flash messenger service

To add and retrieve text messages

$this->flashMessenger->addMessage('error', 'This is a error flash message'); //on the next request you can get all messages from a namespace, or all messages from all namespaces if the namespace is omitted $this->flashMessenger->getMessages('error');

Adding general data, not just messages, has a different method for that, accepting data as key/value pairs

$this->flashMessenger->addData('myData', $someData); // next request $this->flashMessenger->getData('myData');

There are also some predefined namespaces, along with shortcuts to add a message in the predefined namespaces

FlashMessengerInterface::ERROR_NAMESPACE FlashMessengerInterface::WARNING_NAMESPACE FlashMessengerInterface::INFO_NAMESPACE FlashMessengerInterface::SUCCESS_NAMESPACE

using the methods:

public function addError(string|array $error); public function addInfo(string|array $info); public function addWarning(string|array $warning); public function addSuccess(string|array $success);

FlashMessengerRenderer

A class that is able to parse the content of the flash messenger service in an HTML format. It uses the TemplateInterface to parse a partial, sending to the partial template the messages, the service and the renderer itself. There is also a Twig extension provided in dot-twigrenderer, for easy parsing of messages blocks.

Registered services

Dot\FlashMessenger\FlashMessengerInterface::class

The flash messenger service

Dot\FlashMessenger\View\RendererInterface::class

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固