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

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

valkovic/flash
==============

Flash messages for Laravel

v0.1.0(9y ago)0173MITPHP

Since Feb 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/PatrikValkovic/flash-messages)[ Packagist](https://packagist.org/packages/valkovic/flash)[ RSS](/packages/valkovic-flash/feed)WikiDiscussions master Synced 4w ago

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

Flash Messages for Your Laravel App
===================================

[](#flash-messages-for-your-laravel-app)

This package is inspired by [laracast/flash](https://packagist.org/packages/laracasts/flash) package.
Unlike that package, this package allows to use multiple flash messages during one request and set additional properties to HTML tag.

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

[](#installation)

First, pull in the package through Composer.

Run `composer require valkovic/flash`

And then, if using Laravel 5, include the service provider within `config/app.php`.

```
'providers' => [
    \Valkovic\Flash\FlashServiceProvider::class,
],
```

For correct use, you must also register middleware, that cares about loading and saving flash messages during requests. Attach middleware to any group you want, for example I will attach it to `web` group. Settings are at file `app/Http/Kernel.php`.

```
'web' => [
    \Valkovic\Flash\FlashMiddleware::class,
],
```

You can also register Facade for Flash package. Just set alias in `config/app.php`

```
'aliases' => [
    'Flash' => Valkovic\Flash\FlashFacade::class,
];
```

Usage
-----

[](#usage)

Within your controllers, before you perform a redirect...

```
public function store()
{
    flash('Welcome Aboard!');

    return home();
}
```

You may also do:

- `flash('Message', 'none')`
- `flash('Message', 'info')`
- `flash('Message', 'primary')`
- `flash('Message', 'success')`
- `flash('Message', 'warning')`
- `flash('Message', 'error')`
- `flash()->overlay('Modal Message', 'Modal Title')`
- `flash('Message')->important()`

Behind the scenes, this will set `valkovic.flash-messages` key in the session:

During next request, `Valkovic\Flash\FlashMiddleware` will load messages from session and share them to all views as `Flashes` variable.
Then, in your view, you can iterate over them.

```

    @foreach($flashes as $flash)

            {{$flash->message}}

    @endforeach

```

If you set type of message, that type is attach to message as CSS class. If you want to render also that class, you must call `$flash->renderProperties()`. Because this text contains HTML specific tag, you must not escape output from that method.

```

    @foreach($flashes as $flash)
        renderProperties() !!}>
            {{$flash->message}}

    @endforeach

```

> Note that type of messages reflect classes in Twitter Bootstrap.

If you with, you can add more classes or even properties to tag. For example, this code

```
flash('Some message','primary',['class'=>'myClass','id'=>'flashMessage']);
```

with previous blade example will produce following code.

```

            Some message

```

Another usage
-------------

[](#another-usage)

This package provides `Flash` model, `Flash` facade and also `flash` helper function. You are free yo choose, which approach more suits for you. If you want to use `Flash` facade, you will first need to register alias for it, as is noted in Install section.

These commands will have same results.

```
flash('Message','success');
Flash()->success('Message');
flash()->success('Message'); //Note that flash() without parameters return Flash Model

// OR INSIDE CLASS
private $flash;
public function __construct(\Valkovic\Flash\Flash $flash) {
    $this->flash = $flash;
}
public function send(User $user) {
    //store User
    $this->flash->success('Message');
}
```

If you don't want to use Bootstrap specific classes, you are free to use array of properties as second parameter to `message` method or `flash` helper.

```
flash('Message',['class'=>'myClass','id'=>'flashMessage']);
Flash()->message('Message',['class'=>'myClass','id'=>'flashMessage']);

//with template before will produce

            Some message

```

Hiding Flash Messages
---------------------

[](#hiding-flash-messages)

A common desire is to display a flash message for a few seconds, and then hide it. To handle this, write a simple bit of JavaScript. For example, using jQuery, you might add the following snippet just before the closing `` tag. Because you can attach id property to tag, you can refer to `id` property directly.

```
flash('Message',['id'=>'toHide']);

$('#toHide').delay(3000).fadeOut(350);

```

Custom views
------------

[](#custom-views)

This package in current version don't provide views, to show flash messages.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3416d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5438582?v=4)[Patrik Valkovic](/maintainers/PatrikValkovic)[@PatrikValkovic](https://github.com/PatrikValkovic)

---

Top Contributors

[![PatrikValkovic](https://avatars.githubusercontent.com/u/5438582?v=4)](https://github.com/PatrikValkovic "PatrikValkovic (28 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[illuminate/routing

The Illuminate Routing package.

1419.2M2.9k](/packages/illuminate-routing)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M276](/packages/illuminate-pipeline)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)

PHPackages © 2026

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