{"id":16953945,"url":"https://github.com/eliashaeussler/sse","last_synced_at":"2025-03-22T13:31:33.936Z","repository":{"id":178468401,"uuid":"653731176","full_name":"eliashaeussler/sse","owner":"eliashaeussler","description":"🌊 PHP implementation of server-sent events using event streams","archived":false,"fork":false,"pushed_at":"2024-04-29T13:00:53.000Z","size":818,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T16:20:55.126Z","etag":null,"topics":["event-source","event-stream","sse"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eliashaeussler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["eliashaeussler"],"custom":["https://paypal.me/eliashaeussler"]}},"created_at":"2023-06-14T15:59:09.000Z","updated_at":"2024-05-03T08:44:15.949Z","dependencies_parsed_at":"2024-05-03T08:44:07.224Z","dependency_job_id":"65604b85-d5d2-470b-a242-25788ef806a7","html_url":"https://github.com/eliashaeussler/sse","commit_stats":null,"previous_names":["eliashaeussler/sse"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fsse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fsse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fsse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliashaeussler%2Fsse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliashaeussler","download_url":"https://codeload.github.com/eliashaeussler/sse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244962858,"owners_count":20539231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-source","event-stream","sse"],"created_at":"2024-10-13T22:08:22.825Z","updated_at":"2025-03-22T13:31:33.676Z","avatar_url":"https://github.com/eliashaeussler.png","language":"PHP","funding_links":["https://github.com/sponsors/eliashaeussler","https://paypal.me/eliashaeussler"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Screenshot](docs/code-example.png)](#-installation)\n\n# Server-Sent Events in PHP\n\n[![Coverage](https://img.shields.io/coverallsCoverage/github/eliashaeussler/sse?logo=coveralls)](https://coveralls.io/github/eliashaeussler/sse)\n[![Maintainability](https://img.shields.io/codeclimate/maintainability/eliashaeussler/sse?logo=codeclimate)](https://codeclimate.com/github/eliashaeussler/sse/maintainability)\n[![CGL](https://img.shields.io/github/actions/workflow/status/eliashaeussler/sse/cgl.yaml?label=cgl\u0026logo=github)](https://github.com/eliashaeussler/sse/actions/workflows/cgl.yaml)\n[![Tests](https://img.shields.io/github/actions/workflow/status/eliashaeussler/sse/tests.yaml?label=tests\u0026logo=github)](https://github.com/eliashaeussler/sse/actions/workflows/tests.yaml)\n[![Supported PHP Versions](https://img.shields.io/packagist/dependency-v/eliashaeussler/sse/php?logo=php)](https://packagist.org/packages/eliashaeussler/sse)\n\n\u003c/div\u003e\n\nA server implementation of [server-sent events][1], written in PHP.\nIt can be used to stream events back to the client. All event-driven\nfeatures are highly customizable, even custom emitters can be used.\nThe library also provides a PSR-7 compliant event stream implementation.\n\n## 🚀 Features\n\n* Server implementation of [server-sent events (SSE)][1]\n* Highly customizable via interface implementations\n* Self-emitting event stream\n* PSR-7 compliant event stream\n\n## 🔥 Installation\n\n[![Packagist](https://img.shields.io/packagist/v/eliashaeussler/sse?label=version\u0026logo=packagist)](https://packagist.org/packages/eliashaeussler/sse)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/eliashaeussler/sse?color=brightgreen)](https://packagist.org/packages/eliashaeussler/sse)\n\n```bash\ncomposer require eliashaeussler/sse\n```\n\n## ⚡ Usage\n\n```php\nuse EliasHaeussler\\SSE;\n\n// Open event stream\n$eventStream = SSE\\Stream\\SelfEmittingEventStream::create();\n$eventStream-\u003eopen();\n\n// Send event\n$eventStream-\u003esendEvent(new MyCustomEvent($eventData));\n\n// Send message\n$eventStream-\u003esendMessage('myCustomEvent', $eventData);\n\n// Close event stream\n$eventStream-\u003eclose();\n```\n\n## 🎢 Architecture\n\n### Event stream\n\nAll events are sent through [event streams][2]. The library provides an\ninterface [`Stream\\EventStream`](src/Stream/EventStream.php) that abstracts\nall stream parts during the whole event streaming progress.\n\nThe following event stream implementations are currently available:\n\n* [**`Stream\\SelfEmittingEventStream`**](src/Stream/SelfEmittingEventStream.php)\n  sends all stream data to an [emitter](#emitter) that takes care of writing\n  data into an active resource. This is the best working solution in most cases.\n* [**`Stream\\Psr7EventStream`**](src/Stream/Psr7EventStream.php) creates a\n  PSR-7 compliant response during the whole event streaming progress. Note\n  that this response is not emitted on real time.\n\n### Emitter\n\nAll data of a self-emitting event stream is handed over to a given emitter.\nThe library provides an interface [`Stream\\Emitter\\Emitter`](src/Stream/Emitter/Emitter.php)\nthat takes care of all passed data.\n\nThe following emitter implementations are currently available:\n\n* [**`Stream\\Emitter\\RealtimeEmitter`**](src/Stream/Emitter/RealtimeEmitter.php)\n  writes all stream data directly to the active standard output.\n\n### Event\n\nThere are two ways how data can be sent through an active event stream:\n\n1. By sending a prebuilt event by calling `Stream\\EventStream::sendEvent()`.\n2. By sending a plain message by calling `Stream\\EventStream::sendMessage()`.\n\nEvents can be generated by implementing the [`Event\\Event`](src/Event/Event.php)\ninterface. Each event must provide an event name and JSON-serializable\nevent data.\n\n## 🧑‍💻 Contributing\n\nPlease have a look at [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\n## ⭐ License\n\nThis project is licensed under [GNU General Public License 3.0 (or later)](LICENSE).\n\n[1]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events\n[2]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#sending_events_from_the_server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliashaeussler%2Fsse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliashaeussler%2Fsse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliashaeussler%2Fsse/lists"}