PHPackages                             apphp/laravel-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. apphp/laravel-flash

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

apphp/laravel-flash
===================

Simple Flash messages for Laravel Framework Applications

1.8.1(2y ago)324MITPHPPHP &gt;=7.1CI failing

Since Dec 5Pushed 2y ago2 watchersCompare

[ Source](https://github.com/apphp/laravel-flash)[ Packagist](https://packagist.org/packages/apphp/laravel-flash)[ Docs](https://apphp.com)[ RSS](/packages/apphp-laravel-flash/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

[![License: MIT](https://camo.githubusercontent.com/1a2e0606685ce00663bf829868f794fd3fc9c86f8d80cae324734129e0723a58/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d627269676874677265656e2e737667)](https://opensource.org/licenses/MIT)

Simple Flash Messages for Laravel Framework Applications
========================================================

[](#simple-flash-messages-for-laravel-framework-applications)

This package allows to use Bootstrap 3/4/5 flash messaging for Laravel 6+ framework applications.

Requirements
------------

[](#requirements)

- PHP &gt;=7.1
- Laravel 6+
- Bootstrap 3+

License
-------

[](#license)

This project is released under the MIT License.
Copyright © 2020 [ApPHP](https://www.apphp.com/).

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

[](#installation)

Begin by pulling in the package through Composer.

```
composer require apphp/laravel-flash
```

Next, make sure the default CSS classes for your flash message are optimized for Bootstrap. You may either pull in the Bootstrap's CSS within your HTML or layout file, or write your own CSS classes based on them. If you use Bootstrap 3, part of classes, like "primary" and "secondary" will not have styling.

```

```

Usage
-----

[](#usage)

In your controllers, before you perform a redirect or render a view, make a call to the `flash()` function.

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

    return redirect()->route('home');
}
```

The general way to define a flash message is a following:

```
flash()->danger('The error message')->important();
flash()->info('The info message');
```

[![Simple message](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-simple.png)](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-simple.png)

If you want to specify a title for alert, pass 2 arguments in the following way:

```
flash()->success(['Success', 'Operation has been successfully completed']);
```

[![Message with title](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-with-title.png)](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-with-title.png)

But you may use a shorter syntax:

```
flash(['Error', 'The error message'], 'error', true);
flash('The info message', true);
flash('The info message');
```

You may also define the following flash messages:

MethodDescription`flash('your-message', 'primary')`Set the flash type to "primary".`flash('your-message', 'secondary')`Set the flash type to "secondary".`flash('your-message', 'success')`Set the flash type to "success".`flash('your-message', 'warning')`Set the flash type to "warning".`flash('your-message', 'validation')`Set the flash type to "validation".`flash('your-message', 'info')`Set the flash type to "info".`flash('your-message', 'danger')`Set the flash type to "danger".`flash('your-message', 'error')`Set the flash type to "error" (alias to "danger") w/o a close button.`flash('your-message', 'error', true)`Set the flash type to "error" with a close button to the message.`flash('your-message', 'light')`Set the flash type to "light".`flash('your-message', 'dark')`Set the flash type to "dark".You may also define messages, by using Flash facade:

```
use Apphp\Flash\Flash;
```

MethodDescription`Flash::success('your-message')`Set the success flash message.`Flash::error('your-message')`Set the flash type to "error" w/o a close button to the message.`Flash::error('your-message', true)`Set the flash type to "error" with a close button to the message.etc.To show messages on view files, use the following:

```
@include('flash::message')
```

If you need to modify the flash message, you can run:

```
php artisan vendor:publish --provider="Apphp\Flash\FlashServiceProvider"
```

Show Multiple Messages
----------------------

[](#show-multiple-messages)

If you need to flash multiple flash messages, you may simply define them one after another.

```
flash('First Message', 'success');
flash('Second Message', 'warning', true);

return redirect('somewhere');
```

Take in account, that you'll not see flash messages if you don't perform redirect.

Clear Messages
--------------

[](#clear-messages)

If you need to clear flash messages, you may do it in the following way:

```
// All previously defined messages will be removed
flash('First Message', 'error');
flash('Second Message', 'danger')->clear();

// All previously defined messages will be removed
flash('First Message', 'error');
flash('Second Message', 'danger');
Flash::success('Third Message');
flash()->clear();

Flash::success('First Message');
// Only current message will be removed
Flash::error('Second Message')->clear();

return redirect('somewhere');
```

Hide Messages
-------------

[](#hide-messages)

Generally you're expecting from the flash messages to be shown for a few seconds, and then they will be closed (if this message is not important). To handle such behaviour, you may write a simple JavaScript code. For example, using jQuery, you might add the following snippet just before the closing `` tag.

```

    $('div.alert').not('.alert-important').delay(5000).fadeOut(250);

```

or with pure CSS

```

div.alert:not(.alert-important) {
    -webkit-animation: cssAnimation 5s forwards;
    animation: cssAnimation 5s forwards;
}
@keyframes cssAnimation {
    0%   {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}
    90%  {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}
    100% {opacity: 0; height:0; padding:0; margin:0;}
}
@-webkit-keyframes cssAnimation {
    0%   {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}
    90%  {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}
    100% {opacity: 0; height:0; padding:0; margin:0;}
}

```

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

[](#configuration)

To change default messages and enable some extra features you can export the config file:

```
php artisan vendor:publish --tag=laravel-flash:config
```

Customize Views
---------------

[](#customize-views)

To change HTML template of the message or use your own, publish view file and customize it to suit your needs.

```
$ php artisan vendor:publish --tag=laravel-flash:views
```

Now you should have a flash.php file in the config folder of your application. If you need to force to re-publish the config file to use `--force`.

Testing
-------

[](#testing)

To rum unit testing simply do following:

```
./vendor/bin/phpunit vendor\\apphp\\laravel-flash\\tests\\TestFlashMessage.php
```

or your may add additional section to your composer.json file:

```
"scripts": {
    "tests": "phpunit --colors=always",
    "test": "phpunit --colors=always --filter",
}
```

and then rum unit following command:

```
composer tests vendor\\apphp\\laravel-flash\\tests\\TestFlashMessage.php
```

Example
-------

[](#example)

This package doesn't includes Bootstrap or any other styling or frontend assets frameworks, so you need to import all the necessary stylesheets.

```
>

    Document Title

    @include('flash::message')

    Welcome to my website...

```

#### All Types of Messages

[](#all-types-of-messages)

[![All Types of Messages](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-all-types.png)](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-all-types.png)

#### Messages with Titles

[](#messages-with-titles)

[![All Types of Messages](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-with-titles.png)](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-with-titles.png)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Every ~80 days

Recently: every ~236 days

Total

13

Last Release

1026d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0.0

1.5.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9803e512c3636b0cfa0224e247621e178ad0fe34f399a413be9b63148f636b70?d=identicon)[apphp](/maintainers/apphp)

---

Top Contributors

[![apphp](https://avatars.githubusercontent.com/u/5477692?v=4)](https://github.com/apphp "apphp (54 commits)")

---

Tags

apphpflash-messageslaravellaravel-packagelaravel6laravel6-packagephplaravellaravel-packageflash-messageslaravel6laravel6-packageapphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[erag/laravel-pwa

A simple and easy-to-use PWA (Progressive Web App) package for Laravel applications.

16083.3k](/packages/erag-laravel-pwa)[brexis/laravel-workflow

Integerate Symfony Workflow component into Laravel.

283125.6k](/packages/brexis-laravel-workflow)[waad/laravel-profanity-filter

Laravel Profanity Filter - Powerful PHP package for detecting, filtering, and masking profanity in multiple languages. Supports leet speak, custom word lists, case sensitivity, and seamless Laravel integration.

202.9k](/packages/waad-laravel-profanity-filter)

PHPackages © 2026

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