PHPackages                             eliashaeussler/sse - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. eliashaeussler/sse

ActiveLibrary[HTTP &amp; Networking](/categories/http)

eliashaeussler/sse
==================

PHP implementation of server-sent events using event streams

2.0.0(9mo ago)10415.5k↓36.2%[1 issues](https://github.com/eliashaeussler/sse/issues)2GPL-3.0-or-laterPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jun 15Pushed 2w ago1 watchersCompare

[ Source](https://github.com/eliashaeussler/sse)[ Packagist](https://packagist.org/packages/eliashaeussler/sse)[ RSS](/packages/eliashaeussler-sse/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (5)Dependencies (13)Versions (11)Used By (2)

[![Screenshot](docs/code-example.png)](#-installation)

Server-Sent Events in PHP
=========================

[](#server-sent-events-in-php)

[![Coverage](https://camo.githubusercontent.com/336ec3a7b42361de5c74c1806db264d6c7dac3717d4de28f90c5ab09a3ffe3ad/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c73436f7665726167652f6769746875622f656c6961736861657573736c65722f7373653f6c6f676f3d636f766572616c6c73)](https://coveralls.io/github/eliashaeussler/sse)[![CI](https://camo.githubusercontent.com/7e3342fc7c1120b22b049dc46836da1bab8880b7d6724edc6e36f94eb174ec0f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6961736861657573736c65722f7373652f63692e79616d6c3f6c6162656c3d4349266c6f676f3d676974687562)](https://github.com/eliashaeussler/sse/actions/workflows/ci.yaml)[![Supported PHP Versions](https://camo.githubusercontent.com/5ed88814172c0c3265ff61127c56766be86894b611c1bf6b23480cd96c53ce30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f656c6961736861657573736c65722f7373652f7068703f6c6f676f3d706870)](https://packagist.org/packages/eliashaeussler/sse)

A server implementation of [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events), written in PHP. It can be used to stream events back to the client. All event-driven features are highly customizable, even custom emitters can be used. The library also provides a PSR-7 compliant event stream implementation.

🚀 Features
----------

[](#-features)

- Server implementation of [server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
- Highly customizable via interface implementations
- Self-emitting event stream
- PSR-7 compliant event stream

🔥 Installation
--------------

[](#-installation)

[![Packagist](https://camo.githubusercontent.com/b939215eb8192a74a7de9cb189a480c4820b24d1015e147004121429528f16b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6961736861657573736c65722f7373653f6c6162656c3d76657273696f6e266c6f676f3d7061636b6167697374)](https://packagist.org/packages/eliashaeussler/sse)[![Packagist Downloads](https://camo.githubusercontent.com/f639ef1e8ddb74720098a943152dfe25fddfb913ad6129467a19465d667b2edc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6961736861657573736c65722f7373653f636f6c6f723d627269676874677265656e)](https://packagist.org/packages/eliashaeussler/sse)

```
composer require eliashaeussler/sse
```

⚡ Usage
-------

[](#-usage)

```
use EliasHaeussler\SSE;

// Open event stream
$eventStream = SSE\Stream\SelfEmittingEventStream::create();
$eventStream->open();

// Send event
$eventStream->sendEvent(new MyCustomEvent($eventData));

// Send message
$eventStream->sendMessage('myCustomEvent', $eventData);

// Close event stream
$eventStream->close();
```

🎢 Architecture
--------------

[](#-architecture)

### Event stream

[](#event-stream)

All events are sent through [event streams](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#sending_events_from_the_server). The library provides an interface [`Stream\EventStream`](src/Stream/EventStream.php) that abstracts all stream parts during the whole event streaming progress.

The following event stream implementations are currently available:

- [**`Stream\SelfEmittingEventStream`**](src/Stream/SelfEmittingEventStream.php)sends all stream data to an [emitter](#emitter) that takes care of writing data into an active resource. This is the best working solution in most cases.
- [**`Stream\Psr7EventStream`**](src/Stream/Psr7EventStream.php) creates a PSR-7 compliant response during the whole event streaming progress. Note that this response is not emitted on real time.

### Emitter

[](#emitter)

All data of a self-emitting event stream is handed over to a given emitter. The library provides an interface [`Stream\Emitter\Emitter`](src/Stream/Emitter/Emitter.php)that takes care of all passed data.

The following emitter implementations are currently available:

- [**`Stream\Emitter\RealtimeEmitter`**](src/Stream/Emitter/RealtimeEmitter.php)writes all stream data directly to the active standard output.

### Event

[](#event)

There are two ways how data can be sent through an active event stream:

1. By sending a prebuilt event by calling `Stream\EventStream::sendEvent()`.
2. By sending a plain message by calling `Stream\EventStream::sendMessage()`.

Events can be generated by implementing the [`Event\Event`](src/Event/Event.php)interface. Each event must provide an event name and JSON-serializable event data.

🧑‍💻 Contributing
----------------

[](#‍-contributing)

Please have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).

⭐ License
---------

[](#-license)

This project is licensed under [GNU General Public License 3.0 (or later)](LICENSE).

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance77

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 83.4% 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 ~221 days

Total

5

Last Release

272d ago

Major Versions

1.1.1 → 2.0.02025-11-18

PHP version history (4 changes)1.0.0PHP ~8.1.0 || ~8.2.0

1.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.1.1PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

2.0.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16313625?v=4)[Elias Häußler](/maintainers/eliashaeussler)[@eliashaeussler](https://github.com/eliashaeussler)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (497 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (99 commits)")

---

Tags

event-sourceevent-streamsse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eliashaeussler-sse/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B4.4k](/packages/guzzlehttp-psr7)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36826.2k2](/packages/telnyx-telnyx-php)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)[getbrevo/brevo-php

Official PHP SDK for the Brevo API.

1004.1M59](/packages/getbrevo-brevo-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

187738.3k49](/packages/laudis-neo4j-php-client)

PHPackages © 2026

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