PHPackages                             coreplex/notifier - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. coreplex/notifier

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

coreplex/notifier
=================

A php class to simply flash notifications to a session and then display them using a javascript notifier.

v0.2.5(10y ago)21.2k1MITPHPPHP &gt;=5.4.0

Since Apr 10Pushed 10y ago3 watchersCompare

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

READMEChangelog (9)Dependencies (3)Versions (10)Used By (0)

Notifier [![Build Status](https://camo.githubusercontent.com/9012e8e1c9f8f2fe7ac569b24a62ff3bbabc6f0ffc47667c966e896839708901/68747470733a2f2f7472617669732d63692e6f72672f636f7265706c65782f6e6f7469666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/coreplex/notifier) [![Latest Stable Version](https://camo.githubusercontent.com/cd1b7016bf3eb3738d90a62e945c5036e56d42b47657b12305aa59302abeffdc/68747470733a2f2f706f7365722e707567782e6f72672f636f7265706c65782f6e6f7469666965722f762f737461626c65)](https://packagist.org/packages/coreplex/notifier) [![Coverage Status](https://camo.githubusercontent.com/c3ece77287e2d05103103ded3b484396fab595afaad805f3d56267602ad2dcea/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f636f7265706c65782f6e6f7469666965722f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/coreplex/notifier?branch=master) [![License](https://camo.githubusercontent.com/795260a1b16b060123a562800afc52fd52f5b02b5f345caa24ad25d1a428d7c8/68747470733a2f2f706f7365722e707567782e6f72672f636f7265706c65782f6e6f7469666965722f6c6963656e7365)](https://packagist.org/packages/coreplex/notifier)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#notifier----)

A PHP package to simply flash notifications and then render them with a JavaScript notifier. This package also comes with Laravel support out of the box.

- [Installation](#installation)
- [Laravel 5 Integration](#laravel-5-integration)
- [Usage](#usage)
- [Usage With Laravel](#usage-with-laravel)
- [Adding Notifications](#adding-notifications)
- [Rendering Notifications](#rendering-notifications)
- [Setting up a Notifier](#setting-up-a-notifier)
    - [Setting a Template](#setting-a-template)
    - [Setting Notification levels](#setting-notification-levels)
    - [Setting Scripts and Styles](#setting-scripts-and-styles)

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

[](#installation)

This package requires PHP 5.4+, and includes a Laravel 5 Service Provider and Facade.

We recommend installing the package through composer. You can either call `composer require coreplex/notifier` in your command line, or add the following to your `composer.json` and then run either `composer install` or `composer update`to download the package.

```
"coreplex/notifier": "~0.2"
```

Laravel 5 Integration
---------------------

[](#laravel-5-integration)

To use the package with Laravel 5 we firstly need to add the notifier and core service providers to the providers array in `app/config/app.php`.

```
'providers' => array(

  Coreplex\Core\CoreServiceProvider::class,
  Coreplex\Notifier\NotifierServiceProvider::class,

);
```

If you wish to use the facade then add the following to your aliases array in `app/config/app.php`.

```
'aliases' => array(

  Notifier'  => Coreplex\Notifier\Facades\Notifier::class,

);
```

Finally once you've added the service provider run `php artisan vendor:publish` to publish the config file.

Usage
-----

[](#usage)

The notifier is made up of a couple of components; a template parser and the coreplex core session class.

To make the template parser you simply need to make a new instance of the Parser class. This class has no dependencies so it's a simple case of creating the object.

```
$parser = new Coreplex\Notifier\Parser();
```

To see how to use the coreplex core session class check the [docs](https://github.com/coreplex/core).

Once you have the template parser and session you are ready to create the notifier. The notifier also requires the package config as a third parameter.

```
$notifier = new Coreplex\Notifier\Notifier($parser, $session, $config);
```

Usage With Laravel
------------------

[](#usage-with-laravel)

Once you've set up the package to access the notifier you can either user the facade or you can inject the class by its interface.

```
Notifier::render();

public function __construct(\Coreplex\Notifier\Contracts\Notifier $notifier)
{
    $this->notifier = $notifier;
}
```

Adding Notifications
--------------------

[](#adding-notifications)

To add a notification you can either call the `notify` method and pass a notification level, or you can call the notification level as a method. You specify the notification levels in the notifier config, you can see more about this in the [setting up a notifier](#setting-up-a-notifier) section below.

```
$notifier->notify('success');

$notifier->success();
```

To pass data to the notification pass an array of key value pairs.

```
$notifier->notify('success', [
    'title' => 'Success',
]);

$notifier->success([
   'title' => 'Success',
]);
```

You can also add multiple notifications per request and they will all be rendered.

```
$notifier->success(['title' => 'Foo']);
$notifier->error(['title' => 'Bar']);
```

Rendering Notifications
-----------------------

[](#rendering-notifications)

To render notifications simply call the `render` method.

```

```

Setting up a Notifier
---------------------

[](#setting-up-a-notifier)

To add a notifier you simply need to a it into the `notifiers` array in the `notifier.php` config file. By default the package comes with config for the excellent [alertify](http://fabien-d.github.io/alertify.js/) notifier.

```
'notifiers' => [

    'alertify' => [

        'template' => 'alertify.{{ level }}("{{ title }}{{ message }}");',
        'css' => [],
        'scripts' => [],
        'levels' => [
            'info' => 'log',
            'success' => 'success',
            'error' => 'error',
        ],

    ],

],
```

A notifier is registered by adding an array made up of a template and the notification levels, and optionally any css files and js scripts.

### Setting a Template

[](#setting-a-template)

The template is used to render the notifications. When you call the `render` method it will loop through all of the notifications and render them to this template.

The template is always passed the notification level and then is also passed the array of dynamic data. To call access the data you wrap the key in double curly braces like so:

```
'template' => 'notifier.{{ level }}("Hello World!");'
```

If a success notification was called using this template it would be rendered to the following string.

```
notifier.success("Hello World!");

```

It's very like that you wouldn't want to hard code the body of the notification so to access that dynamic data in the template you could use the following template.

```
'template' => 'notifier.{{ level }}("{{ body }}");'
```

Occasionally you may also only want to render data if it's been passed through. For example in the following template it will only render an icon if one has been passed through.

```
'template' => 'notifier.{{ level }}("[if:icon] {{ icon }} [endif] {{ body }}");
```

### Setting Notification levels

[](#setting-notification-levels)

Each notifier may have different names for their levels. To add some consistency the package by default requires an info, success and error level notifications. In the levels array you can specify the name your notifier uses for those levels.

For example with the [alertify](http://fabien-d.github.io/alertify.js/) package it comes with log, success and error
notification levels. So the levels array would look like the following:

```
'levels' => [
    'info' => 'log',
    'success' => 'success',
    'error' => 'error',
],
```

However you may wish for to have access to more levels than that so to register custom levels just add them to the array.

```
'levels' => [
    'info' => 'log',
    'success' => 'success',
    'error' => 'error',
    'custom' => 'fooBar',
],
```

This level can then be called either using the `notify` method or by calling the name on the notifier instance.

```
$notifier->notify('custom');

$notifier->custom();
```

### Setting Scripts and Styles

[](#setting-scripts-and-styles)

If you are using multiple notifiers then you may not wish to load all of the styles or scripts on every request, but only when that notifer is being used. To do this you can set the paths to your styles in the `css` array and the paths to your js files in the `scripts` array.

```
'css' => [
    'path/to/styles.css'
],
'scripts' => [
    'path/to/scripts.js'
],
```

Then to render the styles us the `styles` method and to render the scripts use the `scripts` method.

```

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% 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 ~49 days

Recently: every ~58 days

Total

9

Last Release

3659d ago

### Community

Maintainers

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

---

Top Contributors

[![michaeljennings](https://avatars.githubusercontent.com/u/5189701?v=4)](https://github.com/michaeljennings "michaeljennings (76 commits)")[![DevKingDigital](https://avatars.githubusercontent.com/u/13821111?v=4)](https://github.com/DevKingDigital "DevKingDigital (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coreplex-notifier/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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