PHPackages                             relaystacks/laravel-conduit - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. relaystacks/laravel-conduit

ActiveLibrary[HTTP &amp; Networking](/categories/http)

relaystacks/laravel-conduit
===========================

Laravel broadcast driver for the Conduit ecosystem. Writes events to a Unix socket via relaystacks/conduit-php.

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

Since Jul 2Pushed 1mo agoCompare

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

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

relaystacks/laravel-conduit
===========================

[](#relaystackslaravel-conduit)

Laravel broadcast driver for the RelayStacks Conduit ecosystem — real-time events on shared hosting without Redis, Pusher, or long-running PHP.

Why Conduit
-----------

[](#why-conduit)

Most real-time broadcasting solutions require Redis, a paid service like Pusher, or the ability to run long-lived PHP processes. On shared cPanel hosting, none of these are available.

Conduit solves this by using a Unix domain socket to send events from PHP to a lightweight Node.js relay server that runs under Passenger. The Node server is a "dumb middleman" — Laravel owns all business logic, channel authorization, and presence tracking. No infrastructure beyond what cPanel already provides.

How It Works
------------

[](#how-it-works)

```
Laravel Event (ShouldBroadcast)
    │
    ▼
ConduitBroadcaster (this package)
    │
    ▼
UnixSocketTransport (relaystacks/conduit-php)
    │  JSON + optional HMAC signing
    ▼
Unix domain socket (/home/user/laravel.sock)
    │
    ▼
conduit-echo (Node.js relay)
    │  Socket.IO
    ▼
Browser (Laravel Echo client)

```

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

[](#installation)

```
composer require relaystacks/laravel-conduit
```

The service provider is auto-discovered — no manual registration needed.

Publish the config file:

```
php artisan vendor:publish --tag=conduit-config
```

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

[](#configuration)

### Environment Variables

[](#environment-variables)

VariableDefaultDescription`CONDUIT_SOCKET_PATH`—Absolute path to the Unix socket file`CONDUIT_SECRET``null`Shared HMAC-SHA256 secret (must match conduit-echo)`CONDUIT_TIMEOUT``2`Socket timeout in seconds### Broadcasting Config

[](#broadcasting-config)

Add the `conduit` connection to `config/broadcasting.php`:

```
'connections' => [
    'conduit' => [
        'driver'      => 'conduit',
        'socket_path' => env('CONDUIT_SOCKET_PATH'),
        'secret'      => env('CONDUIT_SECRET'),
        'timeout'     => env('CONDUIT_TIMEOUT', 2),
    ],
],
```

Set the default driver in `.env`:

```
BROADCAST_CONNECTION=conduit

```

Usage
-----

[](#usage)

### Broadcast Events

[](#broadcast-events)

Create events the standard Laravel way:

```
class OrderShipped implements ShouldBroadcast
{
    public function __construct(public Order $order) {}

    public function broadcastOn(): array
    {
        return [new PrivateChannel('orders.' . $this->order->user_id)];
    }

    public function broadcastWith(): array
    {
        return ['order_id' => $this->order->id];
    }
}
```

### Channel Types

[](#channel-types)

**Public channels** — no authorization:

```
Broadcast::channel('news', function () {
    return true;
});
```

**Private channels** — require an authenticated user:

```
Broadcast::channel('orders.{userId}', function (User $user, int $userId) {
    return $user->id === $userId;
});
```

**Presence channels** — track who is online:

```
Broadcast::channel('chat.{roomId}', function (User $user, int $roomId) {
    return ['id' => $user->id, 'name' => $user->name];
});
```

### Guest Presence

[](#guest-presence)

Presence channels can accept unauthenticated users by using a nullable type hint:

```
Broadcast::channel('monitoring', function (?User $user) {
    if ($user) {
        return ['id' => $user->id, 'name' => $user->name];
    }

    $guestId = random_int(100000, 999999);

    return ['id' => 'guest-' . $guestId, 'name' => (string) $guestId];
});
```

Channels with a non-nullable `User` type hint will reject unauthenticated users automatically.

Channel Authorization
---------------------

[](#channel-authorization)

The conduit-echo Node server authorizes private and presence channels by POSTing to Laravel's `/broadcasting/auth` endpoint, forwarding the browser's session cookies.

Define channel callbacks in `routes/channels.php`:

```
// Private — must return true/false
Broadcast::channel('orders.{userId}', function (User $user, int $userId) {
    return $user->id === $userId;
});

// Presence — must return an array with user info
Broadcast::channel('chat.{roomId}', function (User $user, int $roomId) {
    return ['id' => $user->id, 'name' => $user->name];
});
```

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

[](#api-reference)

### `ConduitServiceProvider`

[](#conduitserviceprovider)

Registered automatically via package auto-discovery. Merges the default config and registers the `conduit` broadcast driver with Laravel's `BroadcastManager`.

**Published config tag:** `conduit-config`

### `ConduitBroadcaster`

[](#conduitbroadcaster)

Extends `Illuminate\Broadcasting\Broadcasters\Broadcaster`.

MethodDescription`auth($request)`Authorize a channel subscription. Private channels require authentication; presence channels defer to the channel callback's type hint.`validAuthenticationResponse($request, $result)`Build the JSON auth response. For presence channels, includes `channel_data` with `user_id` and `user_info`.`broadcast(array $channels, $event, array $payload)`Send an event to channels via the transport. Failures are logged, not thrown.Troubleshooting
---------------

[](#troubleshooting)

**Events not reaching the browser:**

- Verify `CONDUIT_SOCKET_PATH` matches between PHP and Node configs
- Check that conduit-echo is running: `GET /health` should return `{"status":"ok"}`
- Check file permissions on the socket file (should be readable/writable by both PHP and Node processes)

**Channel auth failing:**

- Ensure `/broadcasting/auth` is accessible from `localhost` (the Node server POSTs to it)
- Verify cookies/session are being forwarded (check `CONDUIT_AUTH_ENDPOINT` in Node config)
- For presence channels, ensure the channel callback returns an array (not `true`)

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel 10, 11, 12, or 13
- `relaystacks/conduit-php` (auto-required as a dependency)

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

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 (8 commits)")

### Embed Badge

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

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

###  Alternatives

[illuminate/notifications

The Illuminate Notifications package.

483.1M1.2k](/packages/illuminate-notifications)[illuminate/http

The Illuminate Http package.

11938.5M8.3k](/packages/illuminate-http)[mateusjunges/laravel-kafka

A kafka driver for laravel

7263.8M23](/packages/mateusjunges-laravel-kafka)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1239.7k25](/packages/fleetbase-core-api)

PHPackages © 2026

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