PHPackages                             neoflow/flash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. neoflow/flash

Abandoned → [odan/session](/?search=odan%2Fsession)ArchivedLibrary[Framework](/categories/framework)

neoflow/flash
=============

Flash service for Slim 4 and similar PSR-15 compliant frameworks and apps.

2.0.1(3y ago)513MITPHPPHP &gt;=7.3

Since Aug 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jnessier/Flash)[ Packagist](https://packagist.org/packages/neoflow/flash)[ RSS](/packages/neoflow-flash/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (8)Versions (11)Used By (0)

This project is no longer maintained.
=====================================

[](#this-project-is-no-longer-maintained)

Please use other solutions for flash messages with PHP.

---

Flash
=====

[](#flash)

[![Build Status](https://github.com/neoflow/flash/workflows/Tests/badge.svg)](https://github.com/neoflow/flash/actions?query=branch:4.x)[![Latest Stable Version](https://camo.githubusercontent.com/2ba0e43e50f11ab67d9369b56051afbc18b971c3aefbda1a05818e9c4ba0644c/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f666c6173682f763f736572766963653d676974687562)](https://packagist.org/packages/neoflow/flash)[![Total Downloads](https://camo.githubusercontent.com/08f832313a6cb1db3c1b6292aa50ec3b08c08f7dde0b1bc0cfb854cab78a6689/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f666c6173682f646f776e6c6f6164733f736572766963653d676974687562)](//packagist.org/packages/neoflow/flash)[![License](https://camo.githubusercontent.com/958ef26a1f1571b2294646294555d8fa8e4c00198a2d3ee3e956527f3741748e/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f666c6173682f6c6963656e73653f736572766963653d676974687562)](https://packagist.org/packages/neoflow/flash)

Flash service for Slim 4 and similar [PSR-15](https://www.php-fig.org/psr/psr-15/) compliant frameworks and apps.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirement](#requirement)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Session](#session)
- [Contributors](#contributors)
- [History](#history)
- [License](#license)

Requirement
-----------

[](#requirement)

- PHP &gt;= 7.3

Installation
------------

[](#installation)

You have 2 options to install this library.

Via Composer...

```
composer require neoflow/flash
```

...or manually download the latest release from [here](https://github.com/Neoflow/Session/releases/).

Configuration
-------------

[](#configuration)

The following instructions based on [Slim 4](http://www.slimframework.com), in combination with [PHP-DI](https://php-di.org), but should be adaptable for any PSR-11/PSR-15 compliant frameworks and libraries.

Add the service `Neoflow\Flash\Flash` and middleware `Neoflow\Flash\Middleware\FlashMiddleware`to the container definitions...

```
use Neoflow\Flash\Flash;
use Neoflow\Flash\FlashInterface;
use Neoflow\Flash\Middleware\FlashMiddleware;
use Psr\Container\ContainerInterface;

return [
    // ...
    FlashInterface::class => function () {
        $key = '_flash'; // Key as identifier of the values in the storage
        return new Flash($key);
    },
    FlashMiddleware::class => function (ContainerInterface $container) {
        $flash = $container->get(FlashInterface::class);
        return new FlashMiddleware($flash);
    },
    // ...
];
```

...and register the middleware, to use the session as storage for the values.

```
use Neoflow\Flash\Middleware\FlashMiddleware;

$app->add(FlashMiddleware::class);
```

**Please note** The session has to start first, before the middleware can get successfully dispatched.

Alternatively, you can also load values from another storage than the session with a closure middleware...

```
$app->add(function ($request, $handler) use ($container) {
    $storage = [
        // Your custom storage of the values
    ];
    $container->get(FlashInterface::class)->load($storage);
    return $handler->handle($request);
});
```

...or add it directly in the container definitions and skip the middleware.

```
use Neoflow\Flash\Flash;
use Neoflow\Flash\FlashInterface;

return [
    // ...
    FlashInterface::class => function () {
        $key = '_flash'; // Key as identifier of the values in the storage
        $storage = [
            // Your custom storage of the values
        ];
        return new Flash($key, $storage);
    },
    // ...
];
```

When your DI container supports inflectors (e.g. [league/container](https://container.thephpleague.com/3.x/inflectors/)), you can optionally register `Neoflow/Flash/FlashAwareInterface` as inflector to your container definition.

Additionally, you can also use `Neoflow/Flash/FlashAwareTrait` as a shorthand implementation of `Neoflow/Flash/FlashAwareInterface`.

Usage
-----

[](#usage)

The service `Neoflow\Flash\Flash` provides the most needed methods to get access to the values for the current request and to add values for the next request.

```
// Set a value by key for the next request.
$key = 'key'; // Key as identifier of the value
$flash = $flash->set($key, 'Your custom value');

// Get value by key, set for current request.
$default = null; // Default value, when value doesn't exists or is empty (default: null)
$value = $flash->get($key, $default);

// Check whether value by key for current request exists.
$exists = $flash->has($key);

// Count number of values for current request.
$numberOfValues = $flash->count();

// Clear values of current and next request.
$flash = $flash->clear();

// Keep current values for next request. Existing values will be overwritten.
$flash = $flash->keep();

// Load values from storage as reference.
$storage = [
    '_flash' => []
];
$flash = $flash->load($storage);
```

For more advanced use cases, you can also get and set the values for current and next request.

```
// Get values set for next request.
$nextValues = $flash->getNext();

// Set values for next request. Existing values will be overwritten.
$flash = $flash->setNext([
    'key1' => 'value1'
]);

// Get values set for current request.
$currentValues = $flash->getCurrent();

// Set values for current request. Existing values will be overwritten.
$flash = $flash->setCurrent([
    'key1' => 'value1'
]);
```

Nice to know
------------

[](#nice-to-know)

Version 2.0 has been simplified and the message handling implementation has been removed. If you need the message handling please keep using version 1.2.

In earlier times, the library was also part of [Neoflow\\Session](https://github.com/Neoflow/Session) and then moved into a standalone library, to comply with the design principle of separation of concerns.

If you want to use a session service, you can easily combine both libraries as composer packages. The integration and usage of [Neoflow\\Session](https://github.com/Neoflow/Session) is very similar to the current library.

Contributors
------------

[](#contributors)

- Jonathan Nessier, [Neoflow](https://www.neoflow.ch)

If you would like to see this library develop further, or if you want to support me or show me your appreciation, please donate any amount through PayPal. Thank you! 🍻

[![Donate](https://camo.githubusercontent.com/80602243714763ba4467ec539f09f678d206cc112e76d358bf8970c5c90c2b7b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d70617970616c2d626c7565)](https://www.paypal.me/JonathanNessier)

License
-------

[](#license)

Licensed under [MIT](LICENSE).

*Made in Switzerland with 🧀 and ❤️*

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Recently: every ~151 days

Total

10

Last Release

1288d ago

Major Versions

0.1.2 → 1.0.02020-08-10

1.2.0 → 2.0.02022-12-16

PHP version history (2 changes)0.0.1PHP ^7.3

1.2.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1c459ff75e7005e0042d27d315e2238e46c57d08a59eb467a12ceefb75e096f?d=identicon)[jnessier](/maintainers/jnessier)

---

Tags

flash-messagesphp73psr-11psr-15slimslim-frameworkslim4

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/neoflow-flash/health.svg)

```
[![Health](https://phpackages.com/badges/neoflow-flash/health.svg)](https://phpackages.com/packages/neoflow-flash)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M299](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
