PHPackages                             volnix/flashy - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. volnix/flashy

Abandoned → [werx/messages](/?search=werx%2Fmessages)Library[Utility &amp; Helpers](/categories/utility)

volnix/flashy
=============

A wrapper around Symfony's HTTP foundation session flashbag to handle messages and form flash data

3.2.1(8y ago)11032MITPHPPHP &gt;= 5.4

Since Apr 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/volnix/flashy)[ Packagist](https://packagist.org/packages/volnix/flashy)[ Docs](https://github.com/volnix/flashy)[ RSS](/packages/volnix-flashy/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

Flashy
======

[](#flashy)

Simple wrapper around [Symfony's Session](http://symfony.com/doc/current/components/http_foundation/sessions.html) flashbag.

[![Build Status](https://camo.githubusercontent.com/f093fe8591af3a893eae74e6e50766501db7f8b541540dafabe94458a6fc6bda/68747470733a2f2f7472617669732d63692e6f72672f766f6c6e69782f666c617368792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/volnix/flashy) [![Coverage Status](https://camo.githubusercontent.com/4fb69c2b2d2421c36470aa8dc6955ab3750c52913c035e54bb359469ee993cf4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f766f6c6e69782f666c617368792f62616467652e706e67)](https://coveralls.io/r/volnix/flashy) [![Total Downloads](https://camo.githubusercontent.com/adbc2fffb7c2b89c822f49a3271bcdb494ad6015a645e7ab21c8a8a3bef32e4c/68747470733a2f2f706f7365722e707567782e6f72672f766f6c6e69782f666c617368792f646f776e6c6f6164732e706e67)](https://packagist.org/packages/volnix/flashy) [![Latest Stable Version](https://camo.githubusercontent.com/38e40d1414b15260ac796ead6087fc8dcc248cea440cb5f63fea7fdbb4ecd932/68747470733a2f2f706f7365722e707567782e6f72672f766f6c6e69782f666c617368792f762f737461626c652e706e67)](https://packagist.org/packages/volnix/flashy)

There are two pieces to flashy: [Prefill Data](#prefill) and [Messages](#messages).

Prefill Data
-----------------------------------------------

[](#prefill-data)

Often you will want to pre-fill form data from the last request when there are errors with user input. Flashy will accept input from any source, whether it was from POST/GET or a generated array. It is using Symfony's [AutoExpireFlashBag](http://api.symfony.com/2.4/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.html) container so data is cleared after every request whether it is read or not.

To set the form data is done by calling the `set` method:

```
use Symfony\Component\HttpFoundation\Request;
use Volnix\Flashy\FormData;

$request = Request::createFromGlobals();
$form_data = new FormData;
$form_data->set($request->query->all());
```

You would then call `get` to retrieve data, optionally passing a default value to use if the key is not set.

```
use Volnix\Flashy\FormData;

$form_data = new FormData;
$form_data->set(['foo' => 'bar']);

echo $form_data->get('foo'); // bar
echo $form_data->get('bim', 'baz'); // baz
```

To empty the form data storage, call the `clear` function:

```
use Volnix\Flashy\FormData;

$form_data = new FormData;
$form_data->set(['foo' => 'bar']);

echo $form_data->set('foo'); // bar

$form_data->clear();
echo $form_data->get('foo', 'baz'); // baz
```

Messages
--------------------------------------------

[](#messages)

The Messages class will make handling flash messages a breeze. It is loosely tied to [Bootstrap 3](http://getbootstrap.com/) for its alert markup, but this can easily be overridden. It is also using Symfony's [AutoExpireFlashBag](http://api.symfony.com/2.4/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.html) container.

The [\_\_call](http://www.php.net/manual/en/language.oop5.overloading.php#object.call) magic method is used to allow any type of messages for maximum portability.

To set a type of message, you may call any function, passing in a string or an array of messages, e.g.:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);
```

You may also set messages as an array of \[type =&gt; messages\], e.g.:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->setAsArray(['error' => 'foo');
```

To retrieve them as an array, use the `get` function (if not arg is passed, it will return all messages:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);

foreach ($messages->get('error') as $error_message) {
	echo $error_message;
}

$all_messages = $messages->get();
```

The real magic happen when you call the `getFormatted` function:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');
$messages->info(['Message one', 'Message two']);

// print all the error messages:
echo $messages->getFormatted('error');

// print all the messages:
echo $messages->getFormatted();
```

Formatted messages are printed in the following markup:

```

		Message one
		Message two

```

To override the default Bootstrap alert syntax, pass an array of class overrides to the `getFormatted` function:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error('Oh no!');

echo $messages->getFormatted('error', ['error' => 'bip']);
```

will yield:

```

		Oh no!

```

The Messages class also supports nesting of messages, e.g.:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->error(['foo', 'bar' => ['bip', 'bap']]);

echo $messages->getFormatted('error');
```

will yield:

```

		foo

			bar

				bip
				bap

```

To empty the messages storage, call the `clear` function:

```
use Volnix\Flashy\Messages;

$messages = new Messages;
$messages->set(['foo' => 'bar']);

echo $messages->get('foo'); // bar

$messages->clear();
echo $messages->get('foo', 'baz'); // baz
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

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 ~117 days

Recently: every ~279 days

Total

11

Last Release

3251d ago

Major Versions

1.2.1 → 2.02014-05-29

2.1 → 3.02014-05-30

### Community

Maintainers

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

---

Top Contributors

[![volnix](https://avatars.githubusercontent.com/u/1538220?v=4)](https://github.com/volnix "volnix (18 commits)")[![joshmoody](https://avatars.githubusercontent.com/u/1504862?v=4)](https://github.com/joshmoody "joshmoody (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/volnix-flashy/health.svg)

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

###  Alternatives

[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[codefog/contao-news_categories

News Categories bundle for Contao Open Source CMS

3183.3k6](/packages/codefog-contao-news-categories)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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