PHPackages                             ivfuture/laravel-event-notification - 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. ivfuture/laravel-event-notification

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

ivfuture/laravel-event-notification
===================================

This package provides an easy way to integrate real time notifications with Laravel 6, Redis and socket.io .

1.0.0(6y ago)2281MITPHPPHP ^7.2CI failing

Since Jan 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iuliatugui/laravel-event-notification)[ Packagist](https://packagist.org/packages/ivfuture/laravel-event-notification)[ RSS](/packages/ivfuture-laravel-event-notification/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

Laravel Event Notification
==========================

[](#laravel-event-notification)

This package provides an easy way to integrate notifications with Laravel 6, Redis and socket.io . After the installation the user will be able to receive real time notification.

Here are some examples:

```
// at the top of your class
use NotificationTrait;

//Controller's constructor
public function __construct()
{
    //subscribe to all the notification channels from database
    $this->subscribeToNotificationChannels();

    // ...

}

//sending a notification

$notification_channel = NotificationChannel::where('label', 'post-liked')->first();
if (!isset($notification_channel)) {
    return response()->json(['success' => false]);
}

$this->sendNotification($p_sender_id, $p_receiver_id, $p_notifiable_type, $p_notifiable_id, $notification_channel->id, $p_title, $p_description);
```

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

[](#installation)

You can install this package via composer using:

```
composer require ivfuture/laravel-event-notification
```

To register the package you have to add the service provider in your `config/app.php` file:

```
'providers' => [
    // ...
    Ivfuture\EventNotification\NotificationServiceProvider::class,
];
```

Now you should publish the migration with:

```
php artisan vendor:publish --provider="Ivfuture\EventNotification\NotificationServiceProvider"
```

After the migration have been published you can create the tables by running the migrations:

```
php artisan migrate
```

Next, we have to install the npm packages:

```
npm install express socket.io ioredis redis  --save
```

Settings
--------

[](#settings)

First of all, you have to edit your `.env` file to tell Laravel to use the correct `BROADCAST_DRIVER`.

```
BROADCAST_DRIVER=redis

```

If you are using an older version of Laravel you may skip the next step. You have to edit your `config/database.php` file and comment the line that is adding a prefix to redis:

```
'redis' => [

    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'redis'),
        //'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
    ],

   // ...
],
```

Starting the servers
--------------------

[](#starting-the-servers)

Now all you have to do is start the servers.

```
node  vendor/ivfuture/laravel-event-notification/src/socket.js
redis-server --port 3001
```

Usage
-----

[](#usage)

After you've installed the package and done all the settings it's time to integrate the notifications in your project.

First, don't forget to import the trait at the top of your file.

```
use NotificationTrait;
```

### Subscribe to channels notification

[](#subscribe-to-channels-notification)

In your Controller constructor you must subscribe to the channels. You can do this by using `NotificationTrait`'s function `subscribeToNotificationChannels()`. It will search in `notification_channel` table for channels and will automatically subscribe to them.

```
public function __construct()
{
    $this->subscribeToNotificationChannels();

    // ...

}
```

### Send a notification

[](#send-a-notification)

There is also a convenient function for sending a notification:

```
$notification_channel = NotificationChannel::where('label', 'post-liked')->first();

$this->sendNotification($p_sender_id, $p_receiver_id, $p_notifiable_type, $p_notifiable_id, $notification_channel->id, $p_title, $p_description);
```

This will save the notification into the database and will send an event with all its data.

### Get notifications from database

[](#get-notifications-from-database)

You can get the notifications from database:

```
Notification::latest()->where('receiver_id', auth()->user()->id )->get()->groupByDate();
```

This will provide us with notifications grouped by time categories like: `today`, `this week`, `last week` or `older`.

### Receive the notification in view

[](#receive-the-notification-in-view)

To receive real time notifications you must follow this 3 steps:

1 - Import socket.io library

```

```

2 - Create a Socket object.

```
var socket = io('{{ env("APP_URL") }}:3000');
```

Note: By default the server wil listen for port 3000. You can change that by editing the value of `PORT` in your `.env` file.

3 - Listen to the channel from which notification was sent.

```
socket.on("post-liked", function (data) {
    // ...
});
```

Note: If you have many channels, you must listen to all of them.

Example:

```
socket.on("post-liked", function (data) {
    // ...
});

socket.on("post-commented", function (data) {
    // ...
});
```

And finally, don't forget to check if the user is the receiver of notification.

```
if (data.receiver_id == "{{auth()->user()->id}}") {
    // ...
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

2309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29ad6c1ac3d3ddf3ed83b58a29cba7797a0267d3f67aa6b2197345b45954497e?d=identicon)[iuliatugui](/maintainers/iuliatugui)

---

Top Contributors

[![iuliatugui](https://avatars.githubusercontent.com/u/59727642?v=4)](https://github.com/iuliatugui "iuliatugui (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivfuture-laravel-event-notification/health.svg)

```
[![Health](https://phpackages.com/badges/ivfuture-laravel-event-notification/health.svg)](https://phpackages.com/packages/ivfuture-laravel-event-notification)
```

###  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.3M228](/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)[netflie/laravel-notification-whatsapp

Laravel notification driver for WhatsApp

176173.9k](/packages/netflie-laravel-notification-whatsapp)

PHPackages © 2026

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