resonance/resonance-laravel
Composer 安装命令:
composer require resonance/resonance-laravel
包简介
Laravel broadcasting driver + CLI for the resonance WebSocket server (Pusher-compatible).
README 文档
README
Laravel broadcasting driver for Resonance — a self-hosted, Pusher-compatible WebSocket server shipped as a single static binary.
No Redis, no Node, no PHP extensions. The server speaks the Pusher protocol, so Laravel Echo and your existing broadcasting code work unchanged — this package just wires Laravel to it and manages the binary for you.
Requirements
- PHP ≥ 8.1
- Laravel (any currently supported version)
Installation
composer require resonance/resonance-laravel php artisan resonance:install
resonance:install detects your OS and architecture (Linux x86_64/ARM64,
macOS Intel/Apple Silicon, Windows), downloads the matching binary from GitHub
Releases, verifies its SHA-256 checksum and drops it in ./bin.
Configuration
Switching an existing Pusher/Reverb app is environment-only — no code changes:
BROADCAST_CONNECTION=resonance RESONANCE_APP_ID=app1 RESONANCE_KEY=my-key RESONANCE_SECRET=my-secret RESONANCE_HOST=127.0.0.1 RESONANCE_PORT=8080 RESONANCE_SCHEME=http # https if TLS terminates before the server
The service provider registers both the resonance driver and the broadcasting
connection automatically. Optionally publish the config:
php artisan vendor:publish --tag=resonance-config
| Key | Env | Default | |
|---|---|---|---|
host |
RESONANCE_HOST |
127.0.0.1 |
Server host |
port |
RESONANCE_PORT |
8080 |
Server port (WS + REST) |
scheme |
RESONANCE_SCHEME |
http |
https behind TLS |
app_id |
RESONANCE_APP_ID |
app1 |
Must match the server config |
key / secret |
RESONANCE_KEY / RESONANCE_SECRET |
— | Must match the server config |
bin |
RESONANCE_BIN |
base_path('bin/resonance') |
Binary location |
Usage
Start the server (generates a resonance.toml from your config):
php artisan resonance:start
# or with a hand-written config:
php artisan resonance:start --config /etc/resonance.toml
Broadcast as usual:
broadcast(new OrderShipped($order));
Frontend via Laravel Echo (pusher-js transport):
const echo = new Echo({ broadcaster: 'pusher', key: import.meta.env.VITE_RESONANCE_KEY, wsHost: import.meta.env.VITE_RESONANCE_HOST, wsPort: import.meta.env.VITE_RESONANCE_PORT, forceTLS: false, enabledTransports: ['ws', 'wss'], });
Private channels authenticate through the standard /broadcasting/auth
endpoint — nothing to change.
How it works
The package is intentionally thin: the server is Pusher-compatible, so the
driver extends Laravel's own PusherBroadcaster and points it at Resonance.
All the heavy lifting (connection handling, fan-out, backpressure) lives in
the compiled server — your PHP app only sends signed HTTP requests to it.
License
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-10