Download the PHP package 7amoood/laravel-appsync-broadcaster without Composer
On this page you can find all versions of the php package 7amoood/laravel-appsync-broadcaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 7amoood/laravel-appsync-broadcaster
More information about 7amoood/laravel-appsync-broadcaster
Files in 7amoood/laravel-appsync-broadcaster
Package laravel-appsync-broadcaster
Short Description AWS AppSync broadcaster for Laravel Broadcasting - Real-time communication using AWS AppSync Events API
License MIT
Informations about the package laravel-appsync-broadcaster
Laravel AppSync Broadcaster
A Laravel broadcasting driver for AWS AppSync that supports two publishing modes (direct, redis) and two transports (http, websocket) for real-time event delivery.
Features
- Two publishing modes: publish directly from Laravel or queue through Redis
- Two transport layers: send via HTTP or a persistent WebSocket connection
- Background worker support:
php artisan appsync:workerrelays Redis events to AppSync - Channel support: public, private, and presence channels
- Authentication: Cognito-based auth for secured channels
- Retry, buffering, and back-pressure controls
- Frontend integration: WebSocket subscription examples for JavaScript and browsers
- Laravel integration: plugs into Laravel's native broadcasting system
Installation
Install the package via Composer:
The service provider is auto-discovered by Laravel.
Configuration
-
Publish the configuration file:
-
Set AppSync as your default broadcast driver and configure the core variables in
.env: - Optional tuning values from
config/appsync.php:
Note: The AppSync connection is registered automatically. You do not need to manually add it to
config/broadcasting.php.
Modes
| Mode | Description | Worker required |
|---|---|---|
direct |
Laravel publishes straight to AppSync using the configured transport | No |
redis |
Laravel publishes to Redis, and a worker relays the events to AppSync | Yes |
Transports
| Transport | Description | Best for |
|---|---|---|
http |
Sends one or more events using HTTP requests to AppSync | Simple/default setup |
websocket |
Uses a persistent WebSocket connection with batching | Lower overhead / higher throughput |
Supported combinations
APPSYNC_MODE |
APPSYNC_TRANSPORT |
Behavior |
|---|---|---|
direct |
http |
Laravel sends events directly over HTTP |
direct |
websocket |
Laravel sends events directly over WebSocket |
redis |
http |
Laravel publishes to Redis, worker flushes to AppSync over HTTP |
redis |
websocket |
Laravel publishes to Redis, worker relays over persistent WebSocket |
Worker Usage (redis mode)
If you choose APPSYNC_MODE=redis, you must run the worker process:
Common overrides:
Production note: Run the worker under Supervisor or systemd in production.
Usage
Basic Broadcasting
Use Laravel's standard broadcasting flow:
Presence Channels
For presence channels, use Laravel's PresenceChannel as usual:
How publishing works
directmode: your Laravel request publishes to AppSync immediately.redismode: your Laravel request only pushes the event to Redis, and the worker handles delivery.httptransport: uses HTTP requests with retry and exponential backoff.websockettransport: keeps a live connection open and batches events efficiently.
Channel Authentication
For private and presence channels, define authorization logic in routes/channels.php:
Frontend Integration
To subscribe to channels from your frontend application, you need to establish a WebSocket connection to AWS AppSync. Here's how to do it:
JavaScript/Node.js Example
Browser Example (ES6+)
Channel Name Format
Channels follow this format: {namespace}/{channel_type}-{channel_name}
- namespace: From your
APPSYNC_NAMESPACEconfig (default: "default") - channel_type:
publicfor public channelsprivatefor private channelspresencefor presence channels
- channel_name: Your channel identifier
Examples:
default/orders(public channel)default/private-user/123(private channel)default/presence-chat/room1(presence channel)
Authentication Flow
- Frontend sends channel name to your Laravel app's
/broadcasting/authendpoint - Laravel validates the request and returns an AppSync API key
- Frontend uses the API key to establish WebSocket connection
- Frontend subscribes to specific channels using the authenticated connection
Event Structure
Events received from AppSync have this structure:
AWS AppSync Setup
- Create an AppSync Event API in your AWS Console
- Set up Cognito User Pool for authentication
- Create a Cognito App Client with client credentials flow enabled
- Attach Cognito to AppSync as auth method
Error Handling
The broadcaster includes built-in protections for both direct and worker-based delivery:
- HTTP retry logic with exponential backoff and jitter
- Token refresh handling for expired or invalid auth tokens
- Partial failure handling so one failed channel does not stop the rest
- WebSocket reconnect/buffering support for long-lived connections
- Worker buffer limits and stats logging in
redismode
Logging
Important lifecycle and failure details are logged through Laravel's logging system, including:
- Authentication failures
- HTTP retry attempts
- WebSocket disconnects/reconnects
- Redis worker publish/drop statistics
- Configuration and transport errors
Requirements
- PHP ^8.1
- Laravel ^10.0|^11.0|^12.0|^13.0
- AWS AppSync API
- AWS Cognito User Pool
- Redis server (only when using
APPSYNC_MODE=redis)
Compatibility
Composer picks the highest Laravel version your PHP runtime allows.
| Laravel | PHP | Supported |
|---|---|---|
| 13.x | 8.3, 8.4 | ✅ |
| 12.x | 8.2, 8.3, 8.4 | ✅ |
| 11.x | 8.2, 8.3, 8.4 | ✅ |
| 10.x | 8.1, 8.2, 8.3 | ✅ |
Laravel 9 and below are no longer supported; pin ^1.0 of this package if you
need them.
Installing on Laravel 10 or 11: both branches are past their security-EOL, and every release in them carries an unpatched advisory. Recent Composer versions refuse to install advisory-affected packages by default, so a fresh install pinned to
laravel/framework:^10.0or^11.0will fail to resolve — this package is not the cause. Existing lock files are unaffected. To install anyway, opt out withcomposer config policy.advisories.block false. Upgrading to Laravel 12 or 13 is the better answer.
License
This package is open-sourced software licensed under the MIT license.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email the package maintainer instead of using the issue tracker.
All versions of laravel-appsync-broadcaster with dependencies
illuminate/broadcasting Version ^10.0|^11.0|^12.0|^13.0
illuminate/cache Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/redis Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
nesbot/carbon Version ^2.0|^3.0
react/event-loop Version ^1.5
ratchet/pawl Version ^0.4
clue/redis-react Version ^2.7