PHPackages                             hosmelq/sse-saloon - 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. hosmelq/sse-saloon

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

hosmelq/sse-saloon
==================

A Saloon plugin for consuming Server-Sent Events (SSE) streams.

v0.1.0(10mo ago)43.4k↓19.2%2MITPHPPHP ^8.2CI passing

Since Jul 15Pushed 10mo agoCompare

[ Source](https://github.com/hosmelq/sse-saloon)[ Packagist](https://packagist.org/packages/hosmelq/sse-saloon)[ RSS](/packages/hosmelq-sse-saloon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (2)

SSE Saloon Plugin
=================

[](#sse-saloon-plugin)

A [Saloon](https://docs.saloon.dev/) plugin that adds Server-Sent Events support to your HTTP requests. Built on the [hosmelq/sse-php](https://github.com/hosmelq/sse-php) library for WHATWG-compliant SSE parsing.

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

[](#requirements)

- PHP 8.2+

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

[](#installation)

```
composer require hosmelq/sse-saloon
```

Basic Usage
-----------

[](#basic-usage)

Add the `HasServerSentEvents` trait to your request class:

```
use HosmelQ\SSE\Saloon\Traits\HasServerSentEvents;
use Saloon\Http\Request;
use Saloon\Enums\Method;

class StreamNotifications extends Request
{
    use HasServerSentEvents;

    protected Method $method = Method::GET;

    public function resolveEndpoint(): string
    {
        return '/notifications/stream';
    }
}
```

Send the request and process events:

```
$response = $connector->send(new StreamNotifications());

foreach ($response->asEventSource()->events() as $event) {
    echo "Data: {$event->data}\n";
    echo "Event: {$event->event}\n";
    echo "ID: {$event->id}\n";
}
```

Custom Headers and Configuration
--------------------------------

[](#custom-headers-and-configuration)

Override the default methods to add authentication, custom headers, or configure connection settings:

```
use HosmelQ\SSE\Saloon\Traits\HasServerSentEvents;
use Saloon\Http\Request;
use Saloon\Enums\Method;

class CustomizedStream extends Request
{
    use HasServerSentEvents {
        defaultConfig as defaultSSEConfig;
        defaultHeaders as defaultSSEHeaders;
    }

    protected Method $method = Method::GET;

    public function __construct(private int $readTimeout, private string $token) {}

    public function resolveEndpoint(): string
    {
        return '/api/stream';
    }

    protected function defaultConfig(): array
    {
        return array_merge($this->defaultSSEConfig(), [
            'read_timeout' => $this->readTimeout,
        ]);
    }

    protected function defaultHeaders(): array
    {
        return array_merge($this->defaultSSEHeaders(), [
            'Authorization' => 'Bearer ' . $this->token,
        ]);
    }
}
```

For detailed information about event processing, parsing, and handling, see the [hosmelq/sse-php](https://github.com/hosmelq/sse-php) documentation.

Error Handling
--------------

[](#error-handling)

```
use HosmelQ\SSE\SSEProtocolException;

try {
    $response = $connector->send(new EventStreamRequest());

    foreach ($response->asEventSource()->events() as $event) {
    }
} catch (SSEProtocolException $e) {
    echo 'SSE Error: ' . $e->getMessage();
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a list of changes.

Credits
-------

[](#credits)

- [Hosmel Quintana](https://github.com/hosmelq)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance54

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97fd048037c6d5ccfeebf11961838d5db2dca1baca14fefa373230b301389a03?d=identicon)[hosmelq](/maintainers/hosmelq)

---

Top Contributors

[![hosmelq](https://avatars.githubusercontent.com/u/1166143?v=4)](https://github.com/hosmelq "hosmelq (2 commits)")

---

Tags

phpsaloonssestreamphpsaloonssehosmelqserver sent eventsevent source

### Embed Badge

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

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

###  Alternatives

[qruto/laravel-wave

Painless Laravel Broadcasting with SSE.

87048.4k](/packages/qruto-laravel-wave)[hhxsv5/php-sse

A simple and efficient library implemented HTML5's server-sent events by PHP, is used to real-time push events from server to client, and easier than Websocket, instead of AJAX request.

452178.0k3](/packages/hhxsv5-php-sse)[hosmelq/sse

A PHP library for consuming Server-Sent Events (SSE) streams with WHATWG compliance.

143.6k](/packages/hosmelq-sse)[mvanduijker/laravel-mercure-broadcaster

Mercure broadcaster

16866.5k](/packages/mvanduijker-laravel-mercure-broadcaster)[igorw/event-source

A PHP 5.3 library for creating an EventSource stream.

10488.7k2](/packages/igorw-event-source)

PHPackages © 2026

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