Self-Host Your Own Websockets with Laravel - It's This Easy and Fast



21
98938

Have you ever wanted to use Websockets without using an external service like Pusher? In this video I will show you how you finally can leverage the power of websockets in Laravel without any external services. We will use Laravel Echo to work with the sockets on the frontend and Laravel events to trigger events on the server side. The method we will use to operate our Websockets today is a package called laravel-websockets. This package actually imports an instance of Ratchet, a low-level web sockets server, into our Laravel project to allow us to host a websocket server as part of an existing Laravel application. This is convenient because everything is self-contained in one Laravel application. You can run this web socket server inside the Laravel app that requires web sockets, or you can choose to host a standalone application that runs this package for your own self-hosted websocket platform. It can support multiple clients just like other popular websocket services. This package scales well, with over 15,000 concurrent connections maintained using just a simple 512Mb ram VPS server that usually costs around $5 a month. ▼ ▼ ▼ LINKS ▼ ▼ ▼ Next (Optional): Configuring Laravel-Websockets - Understanding the settings: https://youtu.be/V4Nqog5eXuQ Learn Websockets in Detail with My Full (FREE) Course on YouTube: https://www.youtube.com/playlist?list=PLwAKR305CRO9rlj-U9oOi4m2sQaWN6XA8 Laravel-Websockets Package: https://github.com/beyondcode/laravel-websockets Laravel-Websockets Documentation: https://docs.beyondco.de/laravel-websockets/ Installation Snippets: https://docs.beyondco.de/laravel-websockets/1.0/getting-started/installation.html Does This Package Scale?: https://docs.beyondco.de/laravel-websockets/1.0/faq/scaling.html ▼ ▼ ▼ CODE SNIPPETS ▼ ▼ ▼ This was a straightforward setup tutorial, so no GitHub repo is provided. To install in an existing Laravel app 1) Install via composer: composer require beyondcode/laravel-websockets 2) Publish migration files: php artisan vendor:publish —provider=“BeyondCode\LaravelWebSockets\WebSocketsServiceProvider” —tag=“migrations” 3) Publish Configuration Files: php artisan vendor:publish —provider=“BeyondCode\LaravelWebSockets\WebSocketsServiceProvider” —tag=“config” 4) Run Migrations: php artisan migrate To start your web socket server run: php artisan websockets:serve ==== FOLLOW ME ==== Subscribe for New Releases! Subscribe to DevMarketer Insider https://confirmsubscription.com/h/d/5EDC91CF554832D1 Twitter - http://twitter.com/_jacurtis (ask me questions!) ==== QUESTIONS? ==== Leave a comment below and I or someone else can help you. For quick questions you may also want to ask me on Twitter, I respond almost immediately. Email me hello@jacurtis.com Thanks for all your support!

Published by: DevMarketer Published at: 5 years ago Category: چگونه