eliashaeussler/sse
Composer 安装命令:
composer require eliashaeussler/sse
包简介
PHP implementation of server-sent events using event streams
README 文档
README
Server-Sent Events in PHP
A server implementation of 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
- Server implementation of server-sent events (SSE)
- Highly customizable via interface implementations
- Self-emitting event stream
- PSR-7 compliant event stream
🔥 Installation
composer require eliashaeussler/sse
⚡ 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
Event stream
All events are sent through event streams. The library provides an
interface Stream\EventStream that abstracts
all stream parts during the whole event streaming progress.
The following event stream implementations are currently available:
Stream\SelfEmittingEventStreamsends all stream data to an emitter that takes care of writing data into an active resource. This is the best working solution in most cases.Stream\Psr7EventStreamcreates a PSR-7 compliant response during the whole event streaming progress. Note that this response is not emitted on real time.
Emitter
All data of a self-emitting event stream is handed over to a given emitter.
The library provides an interface Stream\Emitter\Emitter
that takes care of all passed data.
The following emitter implementations are currently available:
Stream\Emitter\RealtimeEmitterwrites all stream data directly to the active standard output.
Event
There are two ways how data can be sent through an active event stream:
- By sending a prebuilt event by calling
Stream\EventStream::sendEvent(). - By sending a plain message by calling
Stream\EventStream::sendMessage().
Events can be generated by implementing the Event\Event
interface. Each event must provide an event name and JSON-serializable
event data.
🧑💻 Contributing
Please have a look at CONTRIBUTING.md.
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).
eliashaeussler/sse 适用场景与选型建议
eliashaeussler/sse 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 388.72k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 eliashaeussler/sse 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eliashaeussler/sse 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 388.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 23
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-06-15
