Skip to content

Send real time notification to the user using laravel, redis and socket.io without database

Notifications You must be signed in to change notification settings

dekts/laravel-redis-socket

Repository files navigation

laravel-redis-socket

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.

Install packages

npm install express ioredis socket.io --save

composer require predis/predis

Setting up Redis

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

Starting the Servers

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

Trying it out

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.

You're all done!

If you are stuck somewhere then call me:

[email protected] (+91 9558335853)

About

Send real time notification to the user using laravel, redis and socket.io without database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published