As we all know about web-sockets ,as some times it may go difficult to implement. Here I will Mention the Perfect Simplified steps to implement a Web-socket for Front-end I have chosen Veu.js
Here we are going to Use Redis - So First We have to Install Redis pon our system
sudo apt install redis-server
Lets Start with Laravel
Step 1: Install Following Packages
i)composer require predis/predis,
ii)composer require illuminate/redis
Step 2: Add Following Line in .env file
REDIS_HOST = localhost
REDIS_PASSWORD = null
REDIS_PORT = 6379
REDIS_DB = 0
BROADCAST_DRIVER=redis
Step 3:Now Install laravel-echo-server globally with command
npm install -g laravel-echo-server
Step 4: Now in your Projects Root Folder run following command
laravel-echo-server init
After running above command it will ask you following questions - ans is appropriately as eg below is mine on local machine
? Do you want to run this server in development mode? Yes
? Which port would you like to serve from? 6001
? Which database would you like to use to store presence channel members? redis
? Enter the host of your Laravel authentication server. http://localhost
? Will you be serving on http or https? http
? Do you want to generate a client ID/Key for HTTP API? No
? Do you want to setup cross domain access to the API? No
? What do you want this config to be saved as? laravel-echo-server.json
Step 5: - Now start the Laravel Echo Server By command
laravel-echo-server start
This will look like below :-
Top comments (0)