PHPackages                             prologue/alerts - 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. prologue/alerts

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

prologue/alerts
===============

Prologue Alerts is a package that handles global site messages.

1.4.0(1mo ago)3486.1M—2.1%35[1 PRs](https://github.com/prologuephp/alerts/pulls)20MITPHP

Since Jul 18Pushed 1mo ago8 watchersCompare

[ Source](https://github.com/prologuephp/alerts)[ Packagist](https://packagist.org/packages/prologue/alerts)[ RSS](/packages/prologue-alerts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (10)Versions (22)Used By (20)

Alerts for Laravel (v5 to v12)
==============================

[](#alerts-for-laravel-v5-to-v12)

[![Total Downloads](https://camo.githubusercontent.com/00eefe2cbada371b7cd9586cc4b1843c93ac3b71a3e774238af05f786fd9fc01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f6c6f6775652f616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prologue/alerts)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](license.md)[![Packagist Version](https://camo.githubusercontent.com/e4aad2e52120728805859c869493c608a1c3eda426b72bad865a125cf5b55af5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f6c6f6775652f616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prologue/alerts)

Global site messages in Laravel. Helps trigger notification bubbles with a simple API, both in the current page, and in the next page (using flash data).

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

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Adding Alerts](#adding-alerts)
    - [Adding Alerts Through Alert Levels](#adding-alerts-through-alert-levels)
    - [Flashing Alerts To The Session](#flashing-alerts-to-the-session)
    - [Displaying Alerts](#displaying-alerts)
- [Changelog](#changelog)
- [License](#license)

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

[](#installation)

You can install the package for your Laravel 6+ project through Composer.

```
$ composer require prologue/alerts
```

For Laravel 5.4 and below, register the service provider in `app/config/app.php`.

```
'Prologue\Alerts\AlertsServiceProvider',
```

Add the alias to the list of aliases in `app/config/app.php`.

```
'Alert' => 'Prologue\Alerts\Facades\Alert',
```

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

[](#configuration)

The packages provides you with some configuration options.

To create the configuration file, run this command in your command line app:

```
$ php artisan vendor:publish --provider="Prologue\Alerts\AlertsServiceProvider"
```

The configuration file will be published here: `config/prologue/alerts.php`.

Usage
-----

[](#usage)

### Adding Alerts

[](#adding-alerts)

Since the main `AlertsMessageBag` class which powers the package is an extension of Illuminate's `MessageBag` class, we can leverage its functionality to easily add messages.

```
Alert::add('error', 'Error message');
```

### Adding Alerts Through Alert Levels

[](#adding-alerts-through-alert-levels)

By default, the package has some alert levels defined in its configuration file. The default levels are `success`, `error`, `warning` and `info`. The `AlertsMessageBag` checks if you call one of these levels as a function and registers your alert which you provided with the correct key.

This makes adding alerts for certain alert types very easy:

```
Alert::info('This is an info message.');
Alert::error('Whoops, something has gone wrong.');
```

You can of course add your own alert levels by adding them to your own config file. [See above](#configuration) on how to publish the config file.

### Flashing Alerts To The Session

[](#flashing-alerts-to-the-session)

Sometimes you want to remember alerts when you're, for example, redirecting to another route. This can be done by calling the `flash` method. The `AlertsMessageBag` class will put the current set alerts into the current session which can then be used after the redirect.

```
// Add some alerts and flash them to the session.
Alert::success('You have successfully logged in')->flash();

// Redirect to the admin dashboard.
return Redirect::to('dashboard');

// Display the alerts in the admin dashboard view.
return View::make('dashboard')->with('alerts', Alert::all());
```

### Displaying Alerts

[](#displaying-alerts)

Remember that the `AlertsMessageBag` class is just an extension of Illuminate's `MessageBag` class, which means we can use all of its functionality to display messages.

```
@foreach (Alert::all() as $alert)
    {{ $alert }}
@endforeach
```

Or if you'd like to display a single alert for a certain alert level.

```
@if (Alert::has('success'))
    {{ Alert::first('success') }}
@endif
```

Display all messages for each alert level:

```
@foreach (Alert::getMessages() as $type => $messages)
    @foreach ($messages as $message)
        {{ $message }}
    @endforeach
@endforeach
```

### Checking For Alerts

[](#checking-for-alerts)

Sometimes it can be important to see if alert's do exist, such as only load javascript/styles if they are there are some (helps for better performance).

You can check if there are any errors.

```
Alert::has(); // Will check for any alerts
Alert::has('error'); // Will check for any alerts listed as errors.
```

You can also get the current number of alerts.

```
Alert::count(); // Will give you a total count of all alerts based on all levels within your alerts config.
Alert::count('error'); // Will tell you only the amount of errors and exclude any levels.
```

If you'd like to learn more ways on how you can display messages, please [take a closer look to Illuminate's `MessageBag` class](https://github.com/illuminate/support/blob/master/MessageBag.php).

Credits
-------

[](#credits)

Created by [Dries Vints](https://github.com/driesvints) - he first got the idea after [a blog post](http://toddish.co.uk/blog/global-site-messages-in-laravel-4/) by [Todd Francis](http://toddish.co.uk/). This package uses much of the concepts of his blog post as well as the concept of alert levels which [Illuminate's Log package](https://github.com/illuminate/log) uses. Maintained by [Cristian Tabacitu](https://github.com/tabacitu) thanks to its use in [Backpack for Laravel](http://backpackforlaravel.com/).

Changelog
---------

[](#changelog)

You view the changelog for this package [here](changelog.md).

License
-------

[](#license)

Prologue Alerts is licensed under the [MIT License](license.md).

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity64

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity72

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

Recently: every ~380 days

Total

20

Last Release

59d ago

Major Versions

0.4.8 → 1.0.02022-01-19

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.0

0.4.0-beta.1PHP &gt;=5.4.0

### Community

Maintainers

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

---

Top Contributors

[![driesvints](https://avatars.githubusercontent.com/u/594614?v=4)](https://github.com/driesvints "driesvints (46 commits)")[![tabacitu](https://avatars.githubusercontent.com/u/1032474?v=4)](https://github.com/tabacitu "tabacitu (43 commits)")[![pxpm](https://avatars.githubusercontent.com/u/7188159?v=4)](https://github.com/pxpm "pxpm (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![AbbyJanke](https://avatars.githubusercontent.com/u/487798?v=4)](https://github.com/AbbyJanke "AbbyJanke (2 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (1 commits)")[![Kussie](https://avatars.githubusercontent.com/u/4960791?v=4)](https://github.com/Kussie "Kussie (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![pidgpowell](https://avatars.githubusercontent.com/u/1403420?v=4)](https://github.com/pidgpowell "pidgpowell (1 commits)")[![BigfootPlatform](https://avatars.githubusercontent.com/u/5001228?v=4)](https://github.com/BigfootPlatform "BigfootPlatform (1 commits)")[![amitmerchant1990](https://avatars.githubusercontent.com/u/3647841?v=4)](https://github.com/amitmerchant1990 "amitmerchant1990 (1 commits)")

---

Tags

laravelalertsmessages

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/prologue-alerts/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[anahkiasen/former

A powerful form builder

1.4k1.4M14](/packages/anahkiasen-former)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[cartalyst/alerts

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

3064.2k](/packages/cartalyst-alerts)

PHPackages © 2026

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