PHPackages                             mahavirnahata/stream-bus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mahavirnahata/stream-bus

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mahavirnahata/stream-bus
========================

Redis-backed cross-language stream bus for Laravel.

0.1.0(2mo ago)10MITPHPPHP ^8.2

Since Feb 8Pushed 2mo agoCompare

[ Source](https://github.com/mahavirnahata/stream-bus)[ Packagist](https://packagist.org/packages/mahavirnahata/stream-bus)[ RSS](/packages/mahavirnahata-stream-bus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Stream Bus for Laravel
======================

[](#stream-bus-for-laravel)

A small Redis-backed stream bus for cross-language workers. Supports Redis Streams and Lists, configurable via `config/stream-bus.php`.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11/12
- Redis server

Features
--------

[](#features)

- Redis Streams and Lists drivers
- Consumer command with long-running loop
- Cross-language interoperability (Node, Go, Python)
- Optional dedupe for effectively-once processing
- Multiple consumers configured via config

Install (Packagist)
-------------------

[](#install-packagist)

```
composer require mahavirnahata/stream-bus
```

Install (local development)
---------------------------

[](#install-local-development)

Add a path repository and require the package:

```
{
  "repositories": [
    { "type": "path", "url": "packages/stream-bus" }
  ],
  "require": {
    "mahavirnahata/stream-bus": "*"
  }
}
```

Publish config:

```
php artisan vendor:publish --tag=stream-bus-config
```

Quick start
-----------

[](#quick-start)

```
use MahavirNahata\StreamBus\Facades\StreamBus;

StreamBus::publish('events:outbound', [
    'type' => 'image.process',
    'payload' => ['id' => 123],
]);
```

Run a consumer from Laravel:

```
php artisan stream-bus:consume events:inbound App\Handlers\ImageResultHandler --group=laravel
```

You can also configure consumers in `config/stream-bus.php` and run:

```
php artisan stream-bus:consume
```

End-to-end examples
-------------------

[](#end-to-end-examples)

### Example 1: Laravel dispatches, Node.js listens

[](#example-1-laravel-dispatches-nodejs-listens)

**Laravel (dispatcher)**:

```
use MahavirNahata\StreamBus\Facades\StreamBus;

StreamBus::publish('events:outbound', [
    'type' => 'image.process',
    'payload' => ['id' => 123],
]);
```

**Node.js (listener)**: see `examples/node-consumer.js` reading from `stream-bus:events:outbound`.

### Example 2: Node.js dispatches, Laravel listens

[](#example-2-nodejs-dispatches-laravel-listens)

**Node.js (dispatcher)**: see `examples/node-producer.js` writing to `stream-bus:events:inbound`.

**Laravel (listener)**:

```
