Send real time notification to the user using laravel, redis and socket.io and without database
First, after clone you have to create one virtual host.
npm install express ioredis socket.io --save
composer require predis/predis
As mentioned above Redis should already be installed but you just need to edit your .env file to tell Laravel to use the correct BROADCAST_DRIVER. Add the following line.
BROADCAST_DRIVER=redis
Open two command line tabs and SSH into Homestead
cd
into the root directory of your project
In the first tab, run node socket.js
You should see "Listening on Port 3000"
In the second tab run redis-server --port 3001
You should see a lot of output
Open up two browser windows side by side and in the first one hit the URL:
http://your-project-name.app/fire
And in the second:
http://your-project-name.app/test
Keep refreshing the first window and you should see the second page's content increment.
If you are stuck somewhere then call me:
[email protected] (+91 9558335853)