承接 ostah/laravel-redis-stream 相关项目开发

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

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

ostah/laravel-redis-stream

Composer 安装命令:

composer require ostah/laravel-redis-stream

包简介

Laravel redis stream

README 文档

README

Manage Redis stream messages by firing handler classes per channel. You can assign multiple handler classes to the same channel.

Requirements

  • PHP ^7.4 | ^8.0
  • Laravel / Lumen ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0
  • Redis (phpredis driver recommended)

Installation

Install the package via Composer:

composer require ostah/laravel-redis-stream

Laravel

Publish the config file:

php artisan vendor:publish --tag=laravel-redis-stream-config

Lumen

  1. Register the service provider in bootstrap/app.php:
$app->register(LaravelStream\Redis\StreamServiceProvider::class);
  1. Ensure Redis is registered (add if not already present):
$app->register(Illuminate\Redis\RedisServiceProvider::class);
  1. Copy the config file from vendor/ostah/laravel-redis-stream/config/streaming.php to config/streaming.php.

For more on Redis with Lumen, see the Lumen cache documentation.

Configuration

In config/streaming.php:

  1. Redis connection – Set the connection name under the redis.connection key. This must match a connection defined in config/database.php (e.g. default or a custom stream connection).

  2. Channels and handlers – Define channels and their handler classes:

'channels' => [
    'channel-name' => [
        App\Channels\SomeClassChannel::class,
    ],
],
  1. Trim (optional) – Limit stream length per channel:
'trim' => [
    'channel-name' => 1000, // keep at most 1000 messages
],

We recommend using the phpredis driver for Redis.

Creating a handler class

Generate a channel listener with Artisan (created in app/Channels):

php artisan make:channel-listener SomeClassChannel

Running the channel listener

Listen to all channels:

php artisan stream:run

Listen to a specific channel:

php artisan stream:run --channel=channel-name

Sending messages to a Redis stream

Use the Stream facade to publish messages (xADD):

use LaravelStream\Redis\Facades\Stream;

$messageId = Stream::stream($channel, $data, $trim);
Parameter Type Description
$channel string Channel name
$data mixed Message payload (will be JSON- or msgpack-encoded per config)
$trim int|null Max stream length for this channel. null = use config; 0 = no trimming

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固