roman444uk/yii2-sse 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

roman444uk/yii2-sse

最新稳定版本:v1.0.1

Composer 安装命令:

composer require roman444uk/yii2-sse

包简介

Yii2 SSE is a wrapper for the library libSSE-php. Its used for managing Server Sent Events in Yii2.

README 文档

README

Yii2 SSE is a wrapper for the library libSSE-php. Its used for managing Server Sent Events in Yii2.

Installation

You'll be installing this package through composer.

Run this command within your project folder: composer require roman444uk/yii2-sse

Usage

These steps are for the simple/basic Yii2 project.

Edit your web.php config file which is located usually in app/config/web.php

'components' => [
  ...
  'sse' => [
    'class' => \roman444uk\Yii2SSE\LibSSE::class
  ]
  ...
];

You'll have to create a handler for your SSE instance. Usually located in app/sse/.

use roman444uk\Yii2SSE\SSEBase;

class MessageEventHandler extends SSEBase
{
  public function check()
  {
    return true;
  }

  public function update()
  {
    return "Something Cool";
  }
}

Then, anywhere in your controller:

public function actionIndex()
{
  $sse = Yii::$app->sse;
  $sse->addEventListener('message', new MessageEventHandler());
  $sse->start();
}

More information

For more information on using the SSE functionalites of this package visit: https://github.com/licson0729/libSSE-php

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-06-22