PHPackages                             coderello/laraflash - 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. coderello/laraflash

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

coderello/laraflash
===================

Advanced flash messages for Laravel.

6.0.0(3y ago)15737.2k16[1 issues](https://github.com/coderello/laraflash/issues)[1 PRs](https://github.com/coderello/laraflash/pulls)1MITPHPPHP ^8.1CI failing

Since Sep 19Pushed 2y ago3 watchersCompare

[ Source](https://github.com/coderello/laraflash)[ Packagist](https://packagist.org/packages/coderello/laraflash)[ RSS](/packages/coderello-laraflash/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (2)Versions (17)Used By (1)

[![Laraflash](https://camo.githubusercontent.com/afb70a18b3a684dd392a0353837907ac7635187315ddb36f65b600918054a54c/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c617261666c6173682e706e67)](https://camo.githubusercontent.com/afb70a18b3a684dd392a0353837907ac7635187315ddb36f65b600918054a54c/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c617261666c6173682e706e67)

**Laraflash** provides a handy way to work with the flash messages.

 [![Latest Version](https://camo.githubusercontent.com/c91beb15732892079136b711e2112b4c8b986f77978c0b516c5609914007d2ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636f646572656c6c6f2f6c617261666c6173682e7376673f7374796c653d666c61742d737175617265)](https://github.com/coderello/laraflash/releases) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md) [![StyleCI](https://camo.githubusercontent.com/f029de0f88b8dc07946c0772fa998782513ee276299a0877d0be332a973753d9/68747470733a2f2f7374796c6563692e696f2f7265706f732f3134393336343633392f736869656c64)](https://styleci.io/repos/149364639) [![Quality Score](https://camo.githubusercontent.com/e96a28f27ad7211cf3138f0dfc38e4d29d789e0b0229be4c3fdd0c59de5f8c33/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f636f646572656c6c6f2f6c617261666c6173682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/coderello/laraflash) [![Coverage Status](https://camo.githubusercontent.com/3859f3d2847ef8d44966be6e160fe2817ce6e0d478c543b2c66d566cc44c3ecf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f636f646572656c6c6f2f6c617261666c6173682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/coderello/laraflash/code-structure)

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

[](#installation)

You can install this package via composer using this command:

```
composer require coderello/laraflash
```

After that you need to register the `\Coderello\Laraflash\Middleware\HandleLaraflash::class` middleware after the `\Illuminate\Session\Middleware\StartSession::class` one in the `app\Http\Kernel.php`

You can publish the config file with:

```
php artisan vendor:publish --tag="laraflash-config"
```

Adding flash messages
---------------------

[](#adding-flash-messages)

There are many syntax variations for adding flash messages, so you can choose the one you like the most.

Let's take a look at some of them.

```
use Coderello\Laraflash\Facades\Laraflash;

Laraflash::message()->content('Some content')->title('Some title')->type('success');
```

> `message()` method creates and returns fresh `FlashMessage` instance which can be modified by chaining methods (all methods could be found in the `FlashMessage methods` section).

```
laraflash()->message()->content('Some content')->title('Some title')->type('success');
```

> `Laraflash` facade can be replaced with the `laraflash()` helper as you could saw in the example above.

```
laraflash()->message('Some content', 'Some title')->success();
```

> `message()` method accepts up to five arguments: `$content`, `$title`, `$type`, `$delay`, `$hops`.

```
laraflash('Some content', 'Some title')->success();
```

> Arguments mentioned in the previous example can be passed directly to the `laraflash()` helper.

Rendering flash messages
------------------------

[](#rendering-flash-messages)

Ready flash messages could be rendered using the `render()` method of the `Laraflash` instance.

```
laraflash()->render();
```

> All methods of the `Laraflash` instance (which could be obtained by calling `laraflash()` helper without arguments being passed) could be found in the `Laraflash methods` section.

> Output HTML will be generated using skin, specified in the `laraflash.skin` config. All available skins are listed in the config file.

```

   Danger message.

   Info message.

```

> Default separator between the messages is the ``, which is specified in the `laraflash.separator` config. Feel free to change it if you need.

Example of messages rendered as HTML:

[![Example](example.png)](example.png)

Obtaining flash messages as an array
------------------------------------

[](#obtaining-flash-messages-as-an-array)

Flash messages can be obtained as an array using the `toArray()` method.

```
laraflash()->toArray();
```

Here is the result:

```
[
  [
    "title" => null,
    "content" => "Instant message.",
    "type" => "danger",
    "hops" => 1,
    "delay" => 0,
  ],
]

```

> You can use array representation of flash messages for your API.

`Laraflash` methods
-------------------

[](#laraflash-methods)

#### `message(?string $content = null, ?string $title = null, ?string $type = null, ?int $delay = null, ?int $hops = null): FlashMessage`

[](#messagestring-content--null-string-title--null-string-type--null-int-delay--null-int-hops--null-flashmessage)

Creates and returns fresh `FlashMessage` instance.

#### `render()`

[](#render)

Renders ready flash messages as HTML.

#### `keep(): self`

[](#keep-self)

Adds one more hop to each flash message.

#### `clear(): self`

[](#clear-self)

Deletes all flash messages.

#### `all(): Collection`

[](#all-collection)

Returns the `Collection` instance containing all flash messages.

#### `ready(): Collection`

[](#ready-collection)

Returns the `Collection` instance containing ready flash messages.

#### `touch(): self`

[](#touch-self)

Touches all flash messages (decrements amount of hops and delay, deletes expired messages).

#### `toArray()`

[](#toarray)

Returns an array representation of ready flash messages.

#### `toJson()`

[](#tojson)

Returns JSON representation of ready flash messages.

`FlashMessage` methods
----------------------

[](#flashmessage-methods)

#### `content(?string $content): self`

[](#contentstring-content-self)

Sets the content of the flash message.

#### `title(?string $title): self`

[](#titlestring-title-self)

Sets the title of the flash message.

#### `type(?string $type): self`

[](#typestring-type-self)

Sets the type of the flash message.

#### `danger(): self`

[](#danger-self)

Sets the `danger` type for the flash message.

#### `warning(): self`

[](#warning-self)

Sets the `warning` type for the flash message.

#### `info(): self`

[](#info-self)

Sets the `info` type for the flash message.

#### `success(): self`

[](#success-self)

Sets the `success` type for the flash message.

#### `hops(int $hops): self`

[](#hopsint-hops-self)

Sets the hops amount of the message (the number of requests in which the message will be present).

> Default: 1

#### `delay(int $delay): self`

[](#delayint-delay-self)

Sets the delay of the message (the number of requests in which the message will be waiting to receive the ready state).

> Default: 1

#### `now(): self`

[](#now-self)

Shortcut for `->delay(0)`

#### `keep(): self`

[](#keep-self-1)

Increments the amount of hops.

#### `attribute(string $key, $value = null): self`

[](#attributestring-key-value--null-self)

Sets the custom attribute which will be present in the array representation of the message and could be obtained using the `get()` method.

#### `get(string $key)`

[](#getstring-key)

Returns the value of the attribute.

#### `toArray()`

[](#toarray-1)

Returns an array representation of the message.

#### `toJson()`

[](#tojson-1)

Returns JSON representation of the message.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

📖 License
---------

[](#-license)

**Larflash** is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~228 days

Total

15

Last Release

1211d ago

Major Versions

1.0.1 → 2.0.02019-03-05

2.2.0 → 3.0.02020-03-03

3.0.0 → 4.0.02020-09-09

4.1.0 → 5.0.02022-02-22

5.0.0 → 6.0.02023-03-10

PHP version history (7 changes)0.1.0PHP &gt;=7.1

2.0.0PHP ^7.2

2.2.0PHP ^7.1

4.0.0PHP ^7.3

4.1.0PHP ^7.3|^8.0

5.0.0PHP ^8.0

6.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![hivokas](https://avatars.githubusercontent.com/u/22997803?v=4)](https://github.com/hivokas "hivokas (10 commits)")[![mathiasdonoso](https://avatars.githubusercontent.com/u/2658267?v=4)](https://github.com/mathiasdonoso "mathiasdonoso (5 commits)")[![jamesj2](https://avatars.githubusercontent.com/u/1355847?v=4)](https://github.com/jamesj2 "jamesj2 (2 commits)")[![mikaeljorhult](https://avatars.githubusercontent.com/u/215694?v=4)](https://github.com/mikaeljorhult "mikaeljorhult (2 commits)")[![WimDeMeester](https://avatars.githubusercontent.com/u/7261529?v=4)](https://github.com/WimDeMeester "WimDeMeester (1 commits)")[![wvandeweyer](https://avatars.githubusercontent.com/u/7953548?v=4)](https://github.com/wvandeweyer "wvandeweyer (1 commits)")

---

Tags

advancedflashlaraflashlaravelmessageslaraveladvancedflashmessageslaraflash

### Embed Badge

![Health badge](/badges/coderello-laraflash/health.svg)

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

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.9k69.5k](/packages/grumpydictator-firefly-iii)[firefly-iii/data-importer

Firefly III Data Import Tool.

8045.8k](/packages/firefly-iii-data-importer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[cartalyst/alerts

Alerts allows you to easily pass alert messages to your Laravel views.

2671.7k](/packages/cartalyst-alerts)[ronasit/laravel-helpers

Provided helpers function and some helper class.

2085.6k31](/packages/ronasit-laravel-helpers)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)

PHPackages © 2026

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