This project has been successfully migrated from beyondcode/laravel-websockets (which is abandoned) to Laravel Reverb - the official Laravel WebSocket solution.
beyondcode/laravel-websockets is officially abandoned and no longer maintainedbeyondcode/laravel-websockets (abandoned package)laravel/reverb (official Laravel package)Updated config/broadcasting.php:
- Added reverb connection as the default driver
- Configuration uses Reverb credentials instead of custom WebSocket ports
Three new broadcast events were created to replace the custom WebSocket implementation:
app/Events/NotificationUpdated.phpnotification.{userId}notification.updatedapp/Events/MeetingSynced.phpmeeting.{meetingId}meeting.syncedapp/Events/ProjectSynced.phpproject.{projectId}project.syncedAll WebSocket services now use Laravel’s broadcast system:
NotificationUpdatedService::sendWebSocketUpdateRequest() - Now broadcasts NotificationUpdated eventMeetingSyncService::sendWebSocketMessageRequest() - Now broadcasts MeetingSynced eventProjectSyncService::sendWebSocketMessageRequest() - Now broadcasts ProjectSynced eventLegacy commands have been updated with deprecation warnings:
websocket:start - Now wrapper for reverb:startwebsocket:stop - Deprecated (use CTRL+C or reverb:restart)websocket:reset - Deprecated (no longer needed)websocket:run - Deprecated (replaced by reverb:start)websocket:reset from scheduled tasks (no longer needed)Add these variables to your .env file:
# Broadcasting Driver
BROADCAST_DRIVER=reverb
# Laravel Reverb Configuration
REVERB_APP_ID=your-app-id
REVERB_APP_KEY=your-app-key
REVERB_APP_SECRET=your-app-secret
REVERB_HOST=localhost
REVERB_PORT=8080
REVERB_SCHEME=http
REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080
Generate credentials: ```bash
REVERB_APP_ID=$(openssl rand -hex 16) REVERB_APP_KEY=$(openssl rand -hex 32) REVERB_APP_SECRET=$(openssl rand -hex 32) ```
Development:
bash
php artisan reverb:start
Production (with debug mode):
bash
php artisan reverb:start --debug
Production (as background service): Use a process manager like Supervisor:
[program:reverb]
command=php /path/to/artisan reverb:start
directory=/path/to/project
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/path/to/project/storage/logs/reverb.log
Update your frontend JavaScript to connect to Reverb instead of the legacy WebSocket server.
Before (Legacy):
javascript
const ws = new WebSocket('ws://localhost:9080');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
// Handle notification
};
After (Reverb with Laravel Echo): ```javascript import Echo from ‘laravel-echo’; import Pusher from ‘pusher-js’;
window.Pusher = Pusher;
window.Echo = new Echo({ broadcaster: ‘reverb’, key: process.env.MIX_REVERB_APP_KEY, wsHost: process.env.MIX_REVERB_HOST || ‘localhost’, wsPort: process.env.MIX_REVERB_PORT || 8080, forceTLS: false, disableStats: true, });
// Listen to notifications
window.Echo.channel(notification.${userId})
.listen(‘.notification.updated’, (data) => {
console.log(‘Notification received:’, data);
// Handle notification
});
// Listen to meeting updates
window.Echo.channel(meeting.${meetingId})
.listen(‘.meeting.synced’, (data) => {
console.log(‘Meeting synced:’, data);
// Handle meeting update
});
// Listen to project updates
window.Echo.channel(project.${projectId})
.listen(‘.project.synced’, (data) => {
console.log(‘Project synced:’, data);
// Handle project update
});
```
Install required npm packages:
bash
npm install --save-dev laravel-echo pusher-js
notification.{userId} (public)notification.updatedjson
{
"id": 123,
"name": "Notification message",
"avatar": "https://...",
"seen": false,
"entity_name": "...",
"entity_slug": "...",
"frontend_type": "...",
"type": "...",
"created_at": "...",
"need_link": true,
"highlighted": false,
"is_deleted": false,
"additional_data": {}
}
meeting.{meetingId} (public)meeting.syncedjson
{
"custom_data": {
// Meeting custom data
"force_update_ws": false
}
}
project.{projectId} (public)project.syncedjson
{
"message": "Project update message"
}
# Start Reverb in debug mode
php artisan reverb:start --debug
# In another terminal, test broadcasting
php artisan tinker
>>> broadcast(new App\Events\NotificationUpdated($notification, $userId));
Reverb provides real-time connection monitoring when running with --debug flag.
netstat -an | grep 8080.env configuration is correctstorage/ directoryBROADCAST_DRIVER=reverb in .envShouldBroadcast interface. prefix in listen() methodFor high-traffic applications, enable Redis scaling:
REVERB_SCALING_ENABLED=true
REVERB_SCALING_CHANNEL=reverb
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
Configure in .env:
env
REVERB_APP_MAX_CONNECTIONS=10000
REVERB_APP_MAX_MESSAGE_SIZE=10000
The following files remain in the codebase for reference but are no longer used:
app/Services/WebSocketServerService.php - Legacy Ratchet serverapp/Services/WebSocketClientService.php - Legacy WebSocket clientapp/Managers/WebSocketManager.php - Legacy WebSocket managerapp/Services/IoServerWebsocket.php - Legacy IO serverThese can be safely removed after confirming the migration works correctly.
.env.exampleFor issues or questions: - Laravel Reverb Documentation: https://laravel.com/docs/11.x/reverb - Laravel Broadcasting: https://laravel.com/docs/11.x/broadcasting - Laravel Echo: https://github.com/laravel/echo
Migration completed by: Claude Code Date: $(date +%Y-%m-%d) Laravel Version: 11.x Reverb Version: 1.6.0