PHPackages                             livewave/laravel-sdk - 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. livewave/laravel-sdk

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

livewave/laravel-sdk
====================

Official Laravel SDK for LiveWave real-time events and notifications platform

v1.0.0(3mo ago)05MITPHPPHP ^8.1

Since Jan 13Pushed 3mo agoCompare

[ Source](https://github.com/touhi13/live-wave-laravel)[ Packagist](https://packagist.org/packages/livewave/laravel-sdk)[ Docs](https://github.com/touhi13/live-wave-laravel)[ RSS](/packages/livewave-laravel-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

LiveWave Laravel SDK
====================

[](#livewave-laravel-sdk)

**Optional** Laravel SDK for [LiveWave](https://github.com/touhi13/live-wave) - A self-hosted real-time WebSocket server for Laravel applications.

> **Note:** For basic broadcasting, you **don't need this SDK**! Just use standard Laravel Pusher configuration pointing to your LiveWave server. This SDK is only needed for advanced features like API management, webhooks, and notifications.

Architecture
------------

[](#architecture)

LiveWave works like [Laravel Reverb's multi-app feature](https://laravel.com/docs/12.x/reverb#additional-applications) - your LiveWave server acts as a **central WebSocket server** that multiple Laravel applications can connect to:

```
┌─────────────────────────────────────────────────────────┐
│              LiveWave Server (Reverb)                   │
│         Central WebSocket Server for All Apps           │
├─────────────────────────────────────────────────────────┤
│  Team 1 (E-commerce)  │  Team 2 (CRM)  │  Team 3       │
│  app_id: xxx          │  app_id: yyy    │  app_id: zzz   │
│  app_key              │  app_key        │  app_key       │
│  app_secret           │  app_secret     │  app_secret    │
└─────────────────────────────────────────────────────────┘
         ▲                    ▲                    ▲
         │                    │                    │
    ┌────┴───┐          ┌────┴───┐          ┌────┴───┐
    │ App 1  │          │ App 2  │          │ App 3  │
    │ Laravel│          │ Laravel│          │ Laravel│
    │(Pusher)│          │(Pusher)│          │(Pusher)│
    └────────┘          └────────┘          └────────┘

```

Each Laravel application connects to the **same LiveWave server** but with its own credentials (from their Team dashboard), keeping channels isolated.

Basic Usage (No SDK Required)
-----------------------------

[](#basic-usage-no-sdk-required)

### Step 1: Get Credentials from LiveWave Dashboard

[](#step-1-get-credentials-from-livewave-dashboard)

When you create a Team in LiveWave, you get:

- `app_id`
- `app_key`
- `app_secret`

### Step 2: Configure Your Laravel App

[](#step-2-configure-your-laravel-app)

**`.env` file:**

```
BROADCAST_CONNECTION=pusher

PUSHER_APP_ID=your-app-id-from-livewave
PUSHER_APP_KEY=your-app-key-from-livewave
PUSHER_APP_SECRET=your-app-secret-from-livewave
PUSHER_HOST=your-livewave-server.com
PUSHER_PORT=8080
PUSHER_SCHEME=http
```

**`config/broadcasting.php`:**

```
'pusher' => [
    'driver' => 'pusher',
    'key' => env('PUSHER_APP_KEY'),
    'secret' => env('PUSHER_APP_SECRET'),
    'app_id' => env('PUSHER_APP_ID'),
    'options' => [
        'host' => env('PUSHER_HOST'),
        'port' => env('PUSHER_PORT', 8080),
        'scheme' => env('PUSHER_SCHEME', 'http'),
        'useTLS' => false,
    ],
],
```

### Step 3: Frontend (Laravel Echo)

[](#step-3-frontend-laravel-echo)

```
npm install laravel-echo pusher-js
```

```
import Echo from "laravel-echo";
import Pusher from "pusher-js";

window.Pusher = Pusher;

window.Echo = new Echo({
  broadcaster: "pusher",
  key: import.meta.env.VITE_PUSHER_APP_KEY,
  wsHost: import.meta.env.VITE_PUSHER_HOST,
  wsPort: import.meta.env.VITE_PUSHER_PORT,
  forceTLS: false,
  disableStats: true,
  enabledTransports: ["ws", "wss"],
});
```

**`.env`:**

```
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
```

### Step 4: Broadcast Events

[](#step-4-broadcast-events)

```
// app/Events/MessageSent.php
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class MessageSent implements ShouldBroadcast
{
    use InteractsWithSockets;

    public function __construct(public string $message) {}

    public function broadcastOn(): Channel
    {
        return new Channel('chat');
    }
}

// Dispatch
event(new MessageSent('Hello World!'));
```

**That's it!** No SDK needed for basic broadcasting. ✅

---

When to Use This SDK
--------------------

[](#when-to-use-this-sdk)

This SDK is **optional** and only needed for:

1. **API Management** - Create/manage channels, API keys via code
2. **Webhooks** - Receive events from LiveWave (channel created, member joined, etc.)
3. **Notifications** - Send rich notifications via API
4. **Convenience** - Helper methods and facade for common operations

Installation (For Advanced Features)
------------------------------------

[](#installation-for-advanced-features)

```
composer require livewave/laravel-sdk
```

Then run the installation command:

```
php artisan livewave:install
```

This will:

- Publish the configuration file
- Update your `.env` with LiveWave credentials
- Configure the broadcasting driver

SDK Configuration
-----------------

[](#sdk-configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
LIVEWAVE_APP_ID=your-app-id
LIVEWAVE_APP_KEY=your-app-key
LIVEWAVE_APP_SECRET=your-app-secret
LIVEWAVE_HOST=your-livewave-server.com
LIVEWAVE_PORT=8080
```

For production with SSL:

```
LIVEWAVE_HOST=livewave.yourapp.com
LIVEWAVE_PORT=443
LIVEWAVE_USE_TLS=true
LIVEWAVE_SCHEME=https
LIVEWAVE_WS_SCHEME=wss
```

### Broadcasting Configuration

[](#broadcasting-configuration)

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

```
'connections' => [
    'livewave' => [
        'driver' => 'livewave',
    ],
    // ... other connections
],
```

SDK Usage Examples
------------------

[](#sdk-usage-examples)

### Direct Broadcasting (Using Facade)

[](#direct-broadcasting-using-facade)

```
use LiveWave\Facades\LiveWave;

// Broadcast to a public channel
LiveWave::broadcast('news', 'article.published', [
    'title' => 'Breaking News',
    'content' => 'Something happened...',
]);

// Broadcast to a private channel
LiveWave::broadcastToPrivate('user.123', 'notification', [
    'message' => 'You have a new message',
]);

// Broadcast to multiple channels
LiveWave::broadcastToMany(['channel1', 'channel2'], 'event.name', $data);
```

### Channel Information

[](#channel-information)

```
// Get channel info
$info = LiveWave::getChannelInfo('presence-room.1', ['user_count', 'subscription_count']);

// Get all channels
$channels = LiveWave::getChannels('presence-', ['user_count']);

// Get presence channel users
$users = LiveWave::getPresenceUsers('presence-room.1');
```

### Webhooks

[](#webhooks)

Create a route for webhooks:

```
Route::post('/webhooks/livewave', [WebhookController::class, 'handle'])
    ->middleware('livewave.webhook');
```

The `livewave.webhook` middleware automatically verifies the webhook signature.

```
class WebhookController extends Controller
{
    public function handle(Request $request)
    {
        $event = $request->input('event');
        $data = $request->input('data');

        match($event) {
            'channel.created' => $this->handleChannelCreated($data),
            'channel.deleted' => $this->handleChannelDeleted($data),
            'member.added' => $this->handleMemberAdded($data),
            'member.removed' => $this->handleMemberRemoved($data),
            default => null,
        };

        return response()->json(['status' => 'ok']);
    }
}
```

Private &amp; Presence Channels
-------------------------------

[](#private--presence-channels)

### Private Channels

[](#private-channels)

```
use Illuminate\Broadcasting\PrivateChannel;

public function broadcastOn(): PrivateChannel
{
    return new PrivateChannel('user.' . $this->userId);
}
```

Define authorization in `routes/channels.php`:

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

### Presence Channels

[](#presence-channels)

```
use Illuminate\Broadcasting\PresenceChannel;

public function broadcastOn(): PresenceChannel
{
    return new PresenceChannel('room.' . $this->roomId);
}
```

Authorization with user info:

```
Broadcast::channel('room.{roomId}', function ($user, $roomId) {
    if ($user->canJoinRoom($roomId)) {
        return [
            'id' => $user->id,
            'name' => $user->name,
            'avatar' => $user->avatar_url,
        ];
    }
});
```

### Frontend Listening

[](#frontend-listening)

```
// Public channel
Echo.channel("chat").listen(".message.sent", (e) => {
  console.log("New message:", e.message);
});

// Private channel
Echo.private("user." + userId).listen(".notification", (e) => {
  console.log("Notification:", e);
});

// Presence channel
Echo.join("room." + roomId)
  .here((users) => {
    console.log("Users in room:", users);
  })
  .joining((user) => {
    console.log("User joined:", user);
  })
  .leaving((user) => {
    console.log("User left:", user);
  })
  .listen(".message", (e) => {
    console.log("Message:", e);
  });
```

Testing
-------

[](#testing)

Use the `LiveWaveFake` for testing:

```
use LiveWave\Testing\LiveWaveFake;
use LiveWave\Facades\LiveWave;

public function test_message_is_broadcast()
{
    LiveWave::fake();

    // Perform action that broadcasts
    $this->post('/messages', ['content' => 'Hello']);

    // Assert broadcast was called
    LiveWave::assertBroadcast('chat', 'message.sent', function ($data) {
        return $data['content'] === 'Hello';
    });
}
```

Configuration Options
---------------------

[](#configuration-options)

OptionDescriptionDefault`app_id`Your LiveWave application ID-`app_key`Public key for Echo-`app_secret`Secret for signing-`server.host`LiveWave server host`127.0.0.1``server.port`LiveWave server port`8080``server.scheme`HTTP scheme`http``options.use_tls`Enable TLS`false``options.verify_ssl`Verify SSL certificates`true`Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for recent changes.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance84

Actively maintained with recent releases

Popularity4

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

116d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f428f25bb4faf89dd683bd34bd394befd2c458a359668491ee5c211864a2ce2?d=identicon)[onestdev101](/maintainers/onestdev101)

---

Top Contributors

[![touhi13](https://avatars.githubusercontent.com/u/49831775?v=4)](https://github.com/touhi13 "touhi13 (5 commits)")

---

Tags

laravelnotificationswebsocketpusherrealtimeBroadcastingreverblivewave

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/livewave-laravel-sdk/health.svg)

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

###  Alternatives

[pusher/pusher-http-laravel

\[DEPRECATED\] A Pusher bridge for Laravel

400509.0k3](/packages/pusher-pusher-http-laravel)[basement-chat/basement-chat

Add a real-time chat widget to your Laravel application.

4983.9k](/packages/basement-chat-basement-chat)[vinelab/minion

A Simple WAMP (Web Application Messaging Protocol) server and command line tool

1276.4k](/packages/vinelab-minion)[api-platform/laravel

API Platform support for Laravel

59126.4k5](/packages/api-platform-laravel)[kyrne/websocket

Integrated Pusher replacement.

121.6k1](/packages/kyrne-websocket)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)

PHPackages © 2026

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