PHPackages                             garlic/event-source - 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. garlic/event-source

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

garlic/event-source
===================

Eventsource library for SSE.

4.0.3(8y ago)01.3kPHP

Since Sep 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/garlicservices/event-source-bundle)[ Packagist](https://packagist.org/packages/garlic/event-source)[ RSS](/packages/garlic-event-source/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (4)Dependencies (4)Versions (20)Used By (0)

 [![Hoa](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)

---

 [![Build status](https://camo.githubusercontent.com/d22dff8d47031505bf07311484e8da7b9f8aea755711dc8e28f3d9553c7a6e7c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686f6170726f6a6563742f6576656e74736f757263652f6d61737465722e737667)](https://travis-ci.org/hoaproject/eventsource) [![Code coverage](https://camo.githubusercontent.com/34929ae37e9afaf3210a9bc82c66e55e064afefe2984b3e143be1eeb1cb93928/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f686f6170726f6a6563742f6576656e74736f757263652f6d61737465722e737667)](https://coveralls.io/github/hoaproject/eventsource?branch=master) [![Packagist](https://camo.githubusercontent.com/9c7ed6eb1b40fb44f1a686fb3337a81c3fc4d95e7f905a7ab4292c0e9567e1fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686f612f6576656e74736f757263652e737667)](https://packagist.org/packages/hoa/eventsource) [![License](https://camo.githubusercontent.com/0f735939bd27744d20b99acdaa6b3a6cf27835ed40783c4288da640300b067c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686f612f6576656e74736f757263652e737667)](https://hoa-project.net/LICENSE)

 Hoa is a **modular**, **extensible** and **structured** set of PHP libraries.
 Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\\Eventsource
================

[](#hoaeventsource)

[![Help on IRC](https://camo.githubusercontent.com/4dbc9c9d28c30cf1ab591f4bb8212fe4dbddc734145df532a9bb86b09878d4c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d253233686f6170726f6a6563742d6666303036362e737667)](https://webchat.freenode.net/?channels=#hoaproject)[![Help on Gitter](https://camo.githubusercontent.com/8c4c85951788ff606b1268cb3dd946be05e3054795455d0a7b9250711bc2ac05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d6769747465722d6666303036362e737667)](https://gitter.im/hoaproject/central)[![Documentation](https://camo.githubusercontent.com/7059ad5f1a363f9098686c59d432f01d7330aed9d4b6c8111d985fd64cfc6c60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63756d656e746174696f6e2d6861636b5f626f6f6b2d6666303036362e737667)](https://central.hoa-project.net/Documentation/Library/Eventsource)[![Board](https://camo.githubusercontent.com/fd81654ba14b3aca3a713e1b471bc3fc3ba7b5bb3761ccffd6eea2e2ed1fa5ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f7267616e69736174696f6e2d626f6172642d6666303036362e737667)](https://waffle.io/hoaproject/eventsource)

This library allows to manipulate the [EventSource](http://w3.org/TR/eventsource/) (aka Server-Sent Events) technology by creating a server.

[Learn more](https://central.hoa-project.net/Documentation/Library/Eventsource).

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

[](#installation)

With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`hoa/eventsource`](https://packagist.org/packages/hoa/eventsource):

```
$ composer require hoa/eventsource '~3.0'
```

For more installation procedures, please read [the Source page](https://hoa-project.net/Source.html).

Testing
-------

[](#testing)

Before running the test suites, the development dependencies must be installed:

```
$ composer install
```

Then, to run all the test suites:

```
$ vendor/bin/hoa test:run
```

For more information, please read the [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html).

Quick usage
-----------

[](#quick-usage)

We propose as a quick overview to send an unlimited number of events from the server to the client. The client will display all received events. Thus, in `Server.php`:

```
$server = new Hoa\Eventsource\Server();

while (true) {
    // “tick” is the event name.
    $server->tick->send(time());
    sleep(1);
}
```

And in `index.html`, our client:

```

var output = document.getElementById('output');

try {
    var source    = new EventSource('Server.php');
    source.onopen = function () {
        output.appendChild(document.createElement('hr'));

        return;
    };
    source.addEventListener('tick', function (evt) {
        var samp       = document.createElement('samp');
        samp.innerHTML = evt.data + '\n';
        output.appendChild(samp);

        return;
    });
} catch (e) {
    console.log(e);
}

```

Start your HTTP server and then open `index.html`.

The `Hoa\Eventsource\Server::setReconnectionTime` method allows to redefine the time before the client will reconnect after a disconnection. The `Hoa\Eventsource\Server::getLastId` method allows to retrieve the last ID sent to the client.

Awecode
-------

[](#awecode)

The following awecodes show this library in action:

- [`Hoa\Eventsource`](http://hoa-project.net/Awecode/Eventsource.html): *why and how to use `Hoa\Eventsource\Server`? A simple and daily useful example will illustrate the EventSource technology (or Server-Send Events)*.

Documentation
-------------

[](#documentation)

The [hack book of `Hoa\Eventsource`](https://central.hoa-project.net/Documentation/Library/Eventsource) contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

```
$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open
```

More documentation can be found on the project's website: [hoa-project.net](https://hoa-project.net/).

Getting help
------------

[](#getting-help)

There are mainly two ways to get help:

- On the [`#hoaproject`](https://webchat.freenode.net/?channels=#hoaproject)IRC channel,
- On the forum at [users.hoa-project.net](https://users.hoa-project.net).

Contribution
------------

[](#contribution)

Do you want to contribute? Thanks! A detailed [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html) explains everything you need to know.

License
-------

[](#license)

Hoa is under the New BSD License (BSD-3-Clause). Please, see [`LICENSE`](https://hoa-project.net/LICENSE) for details.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% 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 ~60 days

Recently: every ~3 days

Total

19

Last Release

3172d ago

Major Versions

1.14.09.16 → 2.14.09.172014-09-17

2.15.08.13 → 3.16.01.112016-01-11

1.0.0 → 4.0.02017-08-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/911fb3b905a102069ad8345c1ccb6547636e7fafc75b4da58213d3fe679be486?d=identicon)[garlic](/maintainers/garlic)

---

Top Contributors

[![Hywan](https://avatars.githubusercontent.com/u/946104?v=4)](https://github.com/Hywan "Hywan (77 commits)")[![stephpy](https://avatars.githubusercontent.com/u/232744?v=4)](https://github.com/stephpy "stephpy (2 commits)")[![vonglasow](https://avatars.githubusercontent.com/u/1275202?v=4)](https://github.com/vonglasow "vonglasow (2 commits)")[![imaximius](https://avatars.githubusercontent.com/u/5578878?v=4)](https://github.com/imaximius "imaximius (1 commits)")[![osaris](https://avatars.githubusercontent.com/u/125797?v=4)](https://github.com/osaris "osaris (1 commits)")[![shulard](https://avatars.githubusercontent.com/u/482993?v=4)](https://github.com/shulard "shulard (1 commits)")

---

Tags

httpeventpushlibraryservereventsource

### Embed Badge

![Health badge](/badges/garlic-event-source/health.svg)

```
[![Health](https://phpackages.com/badges/garlic-event-source/health.svg)](https://phpackages.com/packages/garlic-event-source)
```

###  Alternatives

[swow/swow

Coroutine-based multi-platform support engine with a focus on concurrent I/O

1.3k2.1M84](/packages/swow-swow)[amphp/websocket-server

Websocket server for Amp's HTTP server.

124265.1k20](/packages/amphp-websocket-server)[middlewares/response-time

Middleware to save the response time into the X-Response-Time header

14278.7k4](/packages/middlewares-response-time)[middlewares/access-log

Middleware to generate access logs

20121.2k2](/packages/middlewares-access-log)[morozovsk/websocket-examples

examples for simple php websocket server: simple chat (single daemon) - http://sharoid.ru/chat.html , pro chat (master + worker) - http://sharoid.ru/chat2.html , simple game - http://sharoid.ru/game.html

382.3k](/packages/morozovsk-websocket-examples)

PHPackages © 2026

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