Laravel WebSockets is a php package for Laravel 5.7 and up, which handles the server-side of WebSockets for you. It has a web-server, implemented in PHP, that handles incoming WebSocket connections. Laravel WebSockets has been built on top of Ratchet. Also there is support for multi-tenancy, which let you set up a webSockets server and use it for many different applications.
Laravel WebSockets also has a real-time dashboard, that shows you all incoming connections, events and disconnects the moment they happen on your WebSocket server, powered by a real-time chart that gives you key-insights into your WebSocket application metrics, like the number of peak connections, the amount of messages sent and the amount of API messages received.
This package also supports existing packages and applications out there that support Pusher and all the features offered by Pusher, such as private channels, presence channels and even the Pusher HTTP API.
1. First, require it with Composer
composer require beyondcode/laravel-websockets
2. Publish the migration file
php artisan vendor:publish–provider=”BeyondCode\LaravelWebSockets\WebSocketsServiceProvider”–tag=”migrations”
3. Run Migrations command
php artisan migrate
4. publish the config file
php artisan vendor:publish –provider=”BeyondCode\LaravelWebSockets\WebSocketsServiceProvider”–tag=”config”
5. The last step is to fill some environment variables. Make sure that
PUSHER_APP_SECRET are filled in your
6. start the server by executing this command.
php artisan websockets:serve