PHPackages                             mediumart/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. mediumart/notifier

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

mediumart/notifier
==================

Custom hook names for custom laravel notifications channels

1.0.2(5y ago)4711MITPHPPHP &gt;=5.6.4CI failing

Since Jun 20Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (10)Used By (0)

Notifier for laravel 5.3+
=========================

[](#notifier-for-laravel-53)

[![Build Status](https://camo.githubusercontent.com/80b26885774fe025de22c3181ed24b6c724ea9092c23b4d71e5fe3085a040501/68747470733a2f2f7472617669732d63692e6f72672f6d656469756d6172742f6e6f7469666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mediumart/notifier)[![Coverage Status](https://camo.githubusercontent.com/ca772ede60f207c97f7e37fe5de457e1fcc1b4d1ec8cc4a517855884d1a99da3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d656469756d6172742f6e6f7469666965722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mediumart/notifier?branch=master)[![License](https://camo.githubusercontent.com/d051bc63c6e2b680cf23e709132057859117a1ff001978c7dc948ed20b1d4170/68747470733a2f2f706f7365722e707567782e6f72672f6d656469756d6172742f6e6f7469666965722f6c6963656e7365)](https://packagist.org/packages/mediumart/notifier)

Description
-----------

[](#description)

Laravel offers a really simple way of defining custom channels for your app notifications. You just have to return the channel class name through the `via` method of any notification: .

However, using the channel class name inside your notifications objects, can become cumbersome sometimes.

This package allow you to return a custom hook name for custom notification channel, instead of the channel class name through the `via` method of any of your notifications:

```
/**
 * Get the notification channels.
 *
 * @param  mixed  $notifiable
 * @return array|string
 */
public function via($notifiable)
{
    return ['twitter'];
}
```

Imagine that you have 10 or 30 notifications class in the same app, that need to be send through a given channel, well now each of the notifications class is tighly coupled with your custom channel class, and if you happen to change the channel class name or may be decide to use a different implementation for the same channel, you will have to open all of your 30 notifications one by one in order to update the returned class name in their `via` method, and that can be very tedious.

And frankly, i find it more exciting and really cool to be able to define a custom hook name, sort of like built in notifications channels like 'mail', or 'slack', or 'database', or whatever...

So if you do like the idea, let's get started!

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

[](#installation)

Using composer:

```
$ composer require mediumart/notifier

```

If you are using laravel 5.3+ prior to version 5.5, add the service provider in the `providers` array inside `config/app.php`

```
Mediumart\Notifier\NotifierServiceProvider::class
```

Usage
-----

[](#usage)

You need a class that will act as factory for your custom channel. This factory class can be the custom channel class itself if you want, it just need to implements two public static methods: `canHandleNotification` and `createDriver`. Both methods receive as their only argument the driver hook name that is to be created.

The first method `canHandleNotification` should return a Boolean(`true` or `false`) to indicate whether or not the factory is able to create the appropriate driver for the notification.

```
/**
 * Check for the channel capacity.
 *
 * @param  string $driver
 * @return bool
 */
public static function canHandleNotification($driver)
{
    return in_array($driver, ['twitter']);
}
```

The second method `createDriver` will be called by the `ChannelManager` if the first one has returned `true` on this factory, and therefore, should return a fully resolved instance of the appropriate driver to use.

```
/**
 * Create a new driver instance.
 *
 * @param  $driver
 * @return mixed
 */
public static function createDriver($driver)
{
    return static::canHandleNotification($driver)
        ? new static(App::make('someTwitterClient')) : null;
}
```

You can use the provided `notifier:channel` artisan command to generate your channel class, like in the following example:

```
$ php artisan notifier:channel

```

A new channel class will be created under `app/Notifications/Channels/.php`.

Now that you have a fully functionnal factory, you need to register it with your application, the easiest way to do that is to create(if not already exists) a **public** property of type `array`, named `$notificationsChannels` inside your `App\Providers\AppServiceProvider` and list your factory class name in there.

```
/**
* Notifications channels list.
*
* @var array
*/
public $notificationsChannels = [
    \Mediumart\Notifier\Channels\TwitterChannel::class,
];
```

To quickly Taste the package use the [Mediumart\\Notifier\\Examples\\FakeScreenChannel](https://github.com/mediumart/notifier/blob/master/src/Examples/FakeScreenChannel.php) example channel.

License
-------

[](#license)

Mediumart Notifier is an open-sourced software licensed under the [MIT license](https://github.com/mediumart/notifier/blob/master/LICENSE.txt).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 97.9% 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 ~171 days

Recently: every ~341 days

Total

9

Last Release

1878d ago

Major Versions

0.0.6 → 1.0.02017-07-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/76d279b09dcc42437866a38f691f12719533b305de249bdde754a1f453939fc2?d=identicon)[isaacesso](/maintainers/isaacesso)

---

Top Contributors

[![isaacesso](https://avatars.githubusercontent.com/u/6454100?v=4)](https://github.com/isaacesso "isaacesso (46 commits)")[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (1 commits)")

---

Tags

channellaravelnotificationslaravelnotificationchannel

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[ghanem/laravel-smsmisr

Send SMS and SMS Notification via SMS Misr for Laravel

194.8k](/packages/ghanem-laravel-smsmisr)[liliom/laravel-firebase

Laravel FCM (Firebase Cloud Messaging) Notification Channel

2426.1k](/packages/liliom-laravel-firebase)

PHPackages © 2026

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