PHPackages                             stream-lib/rabbitmq-super-stream - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. stream-lib/rabbitmq-super-stream

ActiveLibrary[Queues &amp; Workers](/categories/queues)

stream-lib/rabbitmq-super-stream
================================

PHP client for publishing to RabbitMQ Super Streams via an internal Go helper.

v0.1.5(1mo ago)586↑42.9%MITPHPPHP ^8.2CI passing

Since Apr 14Pushed 1mo agoCompare

[ Source](https://github.com/standard-librarian/rabbitmq-super-stream)[ Packagist](https://packagist.org/packages/stream-lib/rabbitmq-super-stream)[ Docs](https://github.com/standard-librarian/rabbitmq-super-stream)[ RSS](/packages/stream-lib-rabbitmq-super-stream/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

RabbitMQ Super Stream Publisher for PHP
=======================================

[](#rabbitmq-super-stream-publisher-for-php)

`stream-lib/rabbitmq-super-stream` gives PHP applications a native-feeling API for publishing to RabbitMQ Super Streams while delegating stream-specific work to an internal Go helper binary.

The PHP package is the public surface. The Go helper is an implementation detail that is started and managed automatically.

Features
--------

[](#features)

- Native PHP API with no FFI and no custom PHP extension
- RabbitMQ Super Stream publishing powered by the official Go stream client
- Local HTTP+JSON protocol over Unix domain sockets when available
- Automatic fallback to `127.0.0.1` TCP for local helper transport
- Helper reuse across PHP requests per effective config hash
- Connects to an existing RabbitMQ super stream; production code does not declare streams
- Publish confirmations, helper health checks, retries, and structured error mapping
- Plain PHP and Laravel integration

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

[](#requirements)

- PHP `^8.2`
- `proc_open`, `flock`, `json`, and `stream_socket_client`
- Supported bundled helper targets:
    - `linux-amd64`
    - `linux-arm64`
    - `darwin-amd64`
    - `darwin-arm64`

Windows is not supported in v1. The protocol already supports TCP fallback, so Windows support can be added later without changing the public PHP API.

Installation
------------

[](#installation)

```
composer require stream-lib/rabbitmq-super-stream
```

End users do not need Go installed if they use one of the bundled binary targets above.

If you want to override the bundled helper binary:

```
export SUPER_STREAM_HELPER_BINARY=/absolute/path/to/rabbitmq-super-stream-helper
```

Basic Usage
-----------

[](#basic-usage)

```
use StreamLib\RabbitMqSuperStream\SuperStreamClient;

$client = new SuperStreamClient([
    'host' => 'rabbitmq',
    'port' => 5552,
    'username' => 'guest',
    'password' => 'guest',
    'vhost' => '/',
    'super_stream' => 'orders',
]);

$result = $client->publish(
    body: json_encode(['order_id' => 123], JSON_THROW_ON_ERROR),
    routingKey: 'customer-123',
    messageId: 'msg-123',
    contentType: 'application/json',
);
```

`publish()` waits for broker confirmation by default and throws a typed PHP exception on failure.

Configuration
-------------

[](#configuration)

Supported options:

- `host`
- `port`
- `username`
- `password`
- `vhost`
- `super_stream`
- `use_tls`
- `verify_tls`
- `tls_server_name`
- `connect_timeout_ms`
- `confirm_timeout_ms`
- `helper_rpc_timeout_ms`
- `helper_startup_timeout_ms`
- `helper_shutdown_timeout_ms`
- `helper_max_queue_size`
- `helper_transport_preference`
- `helper_runtime_dir`
- `helper_binary`

The helper endpoint is managed internally by the library. Normal application configuration should not set it.

Laravel
-------

[](#laravel)

The package includes a Laravel service provider and facade. See [examples/laravel.md](examples/laravel.md).

Internal Architecture
---------------------

[](#internal-architecture)

- PHP resolves or launches one helper per config hash.
- The helper listens on a Unix socket when it can. If not, it binds a random localhost TCP port.
- By default on Unix hosts, helper runtime files live under `/tmp/ssrs` to keep Unix socket paths short enough for macOS and Linux limits.
- PHP talks to the helper with raw HTTP+JSON over `stream_socket_client`.
- The helper owns one RabbitMQ environment and a per-partition producer set for the configured super stream.
- On startup, the helper queries the configured super stream partitions and connects only to the partitions that already exist.
- Publish requests are serialized through a bounded in-memory queue.
- Confirmation callbacks map broker confirms back to the originating PHP request id.

Local Development
-----------------

[](#local-development)

1. Install PHP dependencies:

```
composer install
```

2. Build the helper for your local machine:

```
make build-helper
```

3. Start RabbitMQ:

```
docker compose -f docker/compose.yml up -d
./docker/setup.sh
```

4. Run unit tests:

```
composer test
```

5. Run integration tests:

```
RUN_STREAM_INTEGRATION_TESTS=1 \
SUPER_STREAM_HELPER_BINARY=$PWD/resources/bin/$(go env GOOS)-$(go env GOARCH)/rabbitmq-super-stream-helper \
composer test:integration
```

6. Run the end-to-end example:

```
php examples/plain-php.php
```

Troubleshooting
---------------

[](#troubleshooting)

- `HelperBinaryNotFoundException`:
    - Build the helper with `make build-helper` or point `SUPER_STREAM_HELPER_BINARY` at a valid binary.
- `HelperStartupException`:
    - Inspect the helper log in the runtime directory. By default this is `/tmp/ssrs` on Unix hosts.
- `AuthenticationException`:
    - Check RabbitMQ stream credentials and vhost permissions.
- `PublishIndeterminateException`:
    - The helper could not prove whether the broker confirmed the publish before the timeout. Your application should treat this as potentially published and make its own idempotency decision.
- Stale runtime files:
    - Remove the relevant runtime directory under `/tmp/ssrs` on Unix, or your configured `helper_runtime_dir`.

Packaging Notes
---------------

[](#packaging-notes)

- End users consume the package through Composer.
- The Go helper is bundled as a standalone binary.
- `scripts/release-binaries.sh` cross-compiles the supported targets and places them under `resources/bin/...`.
- `scripts/package-release-assets.sh` creates `.tar.gz` release assets plus `SHA256SUMS` from the bundled helper binaries.

Publishing To Packagist
-----------------------

[](#publishing-to-packagist)

1. Sign in to Packagist and submit the GitHub repository URL:

```
https://github.com/standard-librarian/rabbitmq-super-stream

```

2. After the package is created on Packagist, copy your Packagist API token from your Packagist profile.
3. Add a GitHub webhook on this repository:

```
Payload URL: https://packagist.org/api/github?username=YOUR_PACKAGIST_USERNAME
Content-Type: application/json
Secret: YOUR_PACKAGIST_API_TOKEN

```

4. Keep SSL verification enabled and use the default push event.
5. For every new package version:

```
git tag v0.1.x
git push origin v0.1.x
```

Packagist should auto-update from the webhook. If it does not, use the package page on Packagist and trigger a manual update.

Verification Summary
--------------------

[](#verification-summary)

The repo includes:

- PHP unit tests for config validation, binary resolution, manifest persistence, transport framing, and helper error mapping
- Go unit tests for config validation, manifest writing, and stream error mapping
- Docker-based integration tests that declare a super stream, publish through PHP, and verify the message is observable through a Go consumer

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance90

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

6

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/959013aaaf26cbb2981fb6ad558c969f86984ac7f883dd02040f075f9610f427?d=identicon)[standard-librarian](/maintainers/standard-librarian)

---

Top Contributors

[![standard-librarian](https://avatars.githubusercontent.com/u/68431349?v=4)](https://github.com/standard-librarian "standard-librarian (8 commits)")

---

Tags

phplaravelrabbitmqmessagingStreamssuper-stream

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stream-lib-rabbitmq-super-stream/health.svg)

```
[![Health](https://phpackages.com/badges/stream-lib-rabbitmq-super-stream/health.svg)](https://phpackages.com/packages/stream-lib-rabbitmq-super-stream)
```

###  Alternatives

[nuwber/rabbitevents

The Nuwber RabbitEvents package

119525.8k4](/packages/nuwber-rabbitevents)[iamfarhad/laravel-rabbitmq

Native ext-amqp RabbitMQ queue driver for Laravel production workloads with connection pooling, publisher confirms, Horizon support, Octane support, quorum queues, and high-performance workers

3317.9k](/packages/iamfarhad-laravel-rabbitmq)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
