PHPackages                             relaystacks/conduit-php - 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. relaystacks/conduit-php

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

relaystacks/conduit-php
=======================

Framework-agnostic Unix socket broadcaster for PHP. The transport core of the Conduit ecosystem.

v1.0.0(1mo ago)0241MITPHPPHP ^8.1

Since Jul 2Pushed 1mo agoCompare

[ Source](https://github.com/relaystacks/conduit-php)[ Packagist](https://packagist.org/packages/relaystacks/conduit-php)[ RSS](/packages/relaystacks-conduit-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (1)

relaystacks/conduit-php
=======================

[](#relaystacksconduit-php)

Framework-agnostic PHP transport for the RelayStacks Conduit broadcasting ecosystem.

Serializes broadcast messages as newline-delimited JSON, optionally signs them with HMAC-SHA256, and writes them to a Unix domain socket. The receiving end is the [`@relaystacks/conduit-echo`](https://github.com/relaystacks/conduit-echo) Node.js relay server.

Zero framework dependencies — requires only PHP 8.1+.

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

[](#installation)

```
composer require relaystacks/conduit-php
```

Quick Start
-----------

[](#quick-start)

```
use RelayStacks\Conduit\UnixSocketTransport;

$transport = new UnixSocketTransport(
    socketPath: '/home/user/laravel.sock',
    secret: 'your-shared-secret', // optional
);

$success = $transport->send('chat-room', 'NewMessage', [
    'user' => 'Alice',
    'text' => 'Hello!',
]);
```

API Reference
-------------

[](#api-reference)

### `TransportInterface`

[](#transportinterface)

The contract for all Conduit transports.

```
public function send(string $channel, string $event, array $data = []): bool;
```

ParamTypeDescription`$channel``string`Channel name (e.g. `presence-chat.1`)`$event``string`Broadcast event name`$data``array`Arbitrary event payload**Returns**`bool``true` if the message was delivered### `UnixSocketTransport`

[](#unixsockettransport)

The default (and only) transport implementation. Sends JSON frames over a Unix domain socket.

#### Constructor

[](#constructor)

ParamTypeDefaultDescription`$socketPath``string`*(required)*Absolute path to the Unix socket file`$timeout``int``2`Connect and write timeout in seconds`$secret``?string``null`Shared HMAC-SHA256 secret. `null` = unsigned messages#### Methods

[](#methods)

- **`send(string $channel, string $event, array $data = []): bool`** — Serialize and write the message. Returns `true` if the full frame was written.

### `ConduitException`

[](#conduitexception)

Domain exception extending `RuntimeException`. Available for consumers to catch Conduit-specific errors.

HMAC Signing
------------

[](#hmac-signing)

When a `$secret` is provided, each message is signed with HMAC-SHA256:

1. The body `{channel, event, data}` is JSON-encoded
2. The HMAC is computed over that JSON string: `hash_hmac('sha256', $json, $secret)`
3. The `hmac` field is appended to the body
4. The complete body (with HMAC) is JSON-encoded again as the final frame

The verifier (conduit-echo) must strip the `hmac` field and re-encode the remaining body to reproduce the signature. This works because both PHP's `json_encode` and JavaScript's `JSON.stringify` produce deterministic key ordering for simple objects.

Wire Format
-----------

[](#wire-format)

Each frame is a single line of JSON terminated by `\n`.

**Unsigned:**

```
{"channel":"chat-room","event":"NewMessage","data":{"user":"Alice","text":"Hello!"}}
```

**Signed:**

```
{"channel":"chat-room","event":"NewMessage","data":{"user":"Alice","text":"Hello!"},"hmac":"a1b2c3..."}
```

Use Without Laravel
-------------------

[](#use-without-laravel)

This package works with any PHP framework or plain PHP scripts. For Laravel integration (broadcast driver, channel authorization, service provider), see [`relaystacks/laravel-conduit`](https://github.com/relaystacks/laravel-conduit).

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

[](#requirements)

- PHP &gt;= 8.1
- Unix-like OS (Unix domain sockets are not available on Windows)

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57075831?v=4)[mohammad ali hadikhah](/maintainers/mahadikhah)[@mahadikhah](https://github.com/mahadikhah)

---

Top Contributors

[![hadikhah](https://avatars.githubusercontent.com/u/71609609?v=4)](https://github.com/hadikhah "hadikhah (3 commits)")

### Embed Badge

![Health badge](/badges/relaystacks-conduit-php/health.svg)

```
[![Health](https://phpackages.com/badges/relaystacks-conduit-php/health.svg)](https://phpackages.com/packages/relaystacks-conduit-php)
```

PHPackages © 2026

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