PHPackages                             khairy/laravel-sse-stream - 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. khairy/laravel-sse-stream

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

khairy/laravel-sse-stream
=========================

Laravel package to provide Server Sent Events functionality for your app.

v2.0(1y ago)6154MITPHPPHP ^7.0|^8.0|^8.1|^8.2|^8.3

Since Jul 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mohamd-khairy/laravel-sse-stream)[ Packagist](https://packagist.org/packages/khairy/laravel-sse-stream)[ Docs](https://github.com/mohamd-khairy/laravel-sse-stream)[ RSS](/packages/khairy-laravel-sse-stream/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (1)Versions (6)Used By (0)

[!\[Latest Version on Packagist\]\[ico-version\]](https://packagist.org/packages/khairy/laravel-sse-stream)[!\[Total Downloads\]\[ico-downloads\]](https://packagist.org/packages/khairy/laravel-sse-stream)

Laravel SSE
===========

[](#laravel-sse)

Laravel package to provide Server Sent Events functionality for your app. You can use this package to show instant notifications to your users without them having to refresh their pages.

Requirements
------------

[](#requirements)

- PHP &gt;= 8
- Laravel 11 s

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

[](#installation)

Via Composer

```
$ composer require khairy/laravel-sse-stream
```

For Laravel &lt; 5.5:

Add Service Provider to `config/app.php` in `providers` section

```
Khairy\LaravelSSEStream\SSEServiceProvider::class,
```

Add Facade to `config/app.php` in `aliases` section

```
'SSE' => Khairy\LaravelSSEStream\Facades\SSEFacade::class,
```

---

Publish package's config, migration and view files by running below command:

```
php artisan vendor:publish --provider="Khairy\LaravelSSEStream\SSEServiceProvider"
```

Run `php artisan migrate` to create `sselogs` table.

Setup SSE
---------

[](#setup-sse)

Setup config options in `config/sse.php` file and then add this in your view/layout file:

```
@include('sse::view')
```

Usage
-----

[](#usage)

Syntax:

```
/**
 * @param string $message : notification message
 * @param string $type : alert, success, error, warning, info
 * @param string $event : Type of event such as "EmailSent", "UserLoggedIn", etc
 */
SSEFacade::notify($message, $type = 'info', $event = 'message')
```

To show popup notifications on the screen, in your controllers/event classes, you can do:

```
use Khairy\LaravelSSEStream\Facades\SSEFacade;

public function myMethod()
{
    SSEFacade::notify('hello world....');

    // or via helper
    sse_notify('hi there');
}
```

Customizing Notification Library
--------------------------------

[](#customizing-notification-library)

By default, package uses [noty](https://github.com/mohamd-khairy/laravel-sse-stream) for showing notifications. You can customize this by modifying code in `resources/views/vendor/sse/view.blade.php` file.

Customizing SSE Events
----------------------

[](#customizing-sse-events)

By default, pacakge uses `message` event type for streaming response:

```
SSEFacade::notify($message, $type = 'notification', $event = 'message')
```

Notice `$event = 'message'`. You can customize this, let's say you want to use `login` as SSE event type:

```
use Khairy\LaravelSSEStream\Facades\SSEFacade;

public function myMethod()
{
    SSEFacade::notify('hello world....', 'notification', 'login');

    // or via helper
    sse_notify('hi there', 'notification', 'login');
}
```

Then you need to handle this in your view yourself like this:

javascript
==========

[](#javascript)

```

var es = new EventSource("{{route('__sse_stream__')}}");

es.addEventListener("UserLoggedIn", function (e) {
    var data = JSON.parse(e.data);
    alert(data.message);
}, false);

```

vuejs
=====

[](#vuejs)

```

    Server-Sent Events in Vue.js

      {{ message.data }}

export default {
  data() {
    return {
      eventSource: null, // To hold the EventSource instance
      messages: [] // To hold the received messages
    };
  },
  mounted() {
    this.startSSE();
  },
  beforeDestroy() {
    this.stopSSE();
  },
  methods: {
    startSSE() {
      this.eventSource = new EventSource('/sse/sse_stream');

      this.eventSource.onmessage = (event) => {
        const data = JSON.parse(event.data);
        this.messages.push(data);
      };

      this.eventSource.addEventListener('reconnect', (event) => {
        console.log('Reconnecting SSE...');
        this.stopSSE();
        setTimeout(this.startSSE, 1000); // Reconnect after 1 second
      });

      this.eventSource.onerror = (event) => {
        if (this.eventSource.readyState === EventSource.CLOSED) {
          console.error('SSE connection was closed.');
        } else {
          console.error('SSE encountered an error:', event);
        }
      };
    },
    stopSSE() {
      if (this.eventSource) {
        this.eventSource.close();
        this.eventSource = null;
      }
    }
  }
};

/* Add any necessary styles here */

```

Credits
-------

[](#credits)

- [Mohamed Khairy](https://github.com/mohamd-khairy)
- [All Contributors](https://github.com/mohamd-khairy/laravel-sse-stream/graphs/contributors "# laravel-sse-stream")

License
-------

[](#license)

Please see the [license file](license.md) for more information.

"# laravel-sse-stream"

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~8 days

Total

5

Last Release

673d ago

Major Versions

v1.0.3 → v2.02024-08-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22400438?v=4)[mohamed khairy](/maintainers/mohamd-khairy)[@mohamd-khairy](https://github.com/mohamd-khairy)

---

Top Contributors

[![mohamd-khairy](https://avatars.githubusercontent.com/u/22400438?v=4)](https://github.com/mohamd-khairy "mohamd-khairy (11 commits)")

---

Tags

eventlaravelservernotificationssserealtimepollingSever Sent Events

### Embed Badge

![Health badge](/badges/khairy-laravel-sse-stream/health.svg)

```
[![Health](https://phpackages.com/badges/khairy-laravel-sse-stream/health.svg)](https://phpackages.com/packages/khairy-laravel-sse-stream)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[sarfraznawaz2005/laravel-sse

Laravel package to provide Server Sent Events functionality for your app.

484.7k](/packages/sarfraznawaz2005-laravel-sse)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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