承接 murdej/sse 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

murdej/sse

最新稳定版本:1.0.1

Composer 安装命令:

composer require murdej/sse

包简介

PHP server site event helper

README 文档

README

This PHP library simplifies the use of Server-Sent Events (SSE) in your PHP applications.

Installation

You can install this library via Composer:

composer require murdej/sse

Usage

Here's a basic example of how to use the library:

<?php

use Murdej\Sse\SseService;

require_once __DIR__ . '/../vendor/autoload.php';

$sse = new SSEService();

for ($i = 0; $i < 4; $i++) {
    $sse->sendMessage(['index' => $i, 'dt' => time()]);
    sleep(1);
}

Client site JavaScript

Here's an example of how to use this library with JavaScript on the client side:

const es = new EventSource('./sse-service.php');

es.onmessage = (messsage) => {
    log.innerText += messsage.data + "\n"
}
es.onerror = (ev) => {
    es.close();
}

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

License

This library is licensed under the MIT License.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-28