Chirag Chhuchha
Chirag Chhuchha

Reputation: 395

what is good to use with laravel for real time application?

I'm new to work with real time application and i search for many articles related to real time applications and i stuck by seeing lots of options like ReactJs with Socket.Io or VueJs with Pusher, and many others for working with Laravel Echo and Broadcast events. i also take a look to Laravel documentation which refers that i can use Redis, Pusher or Socket.Io to triggers real time trigger to my client pages. so please anyone guide me through these as i said i'm new for Broadcasting events.

Upvotes: 2

Views: 5907

Answers (3)

Vandolph Reyes
Vandolph Reyes

Reputation: 620

You have three options. Either Ajax, WebSocket or Realtime technologies.

In ajax, you need to use setInterval() to check every second.

setInvertal(function(){
   fetch_notifications();
}, 1000);

In websocket. It's free but it requires nodejs. Check this. It's laravel 4 but you can easily update to laravel 5. http://www.volkomenjuist.nl/blog/2013/10/20/laravel-4-and-nodejsredis-pubsub-realtime-notifications/

Lastly, using realtime web technologies. Most of them are giving free, it up to you if you want to upgrade your account. Check this lists. https://www.leggetter.co.uk/real-time-web-technologies-guide/ Laravel recommends using pusher, its good. For my self, I would recommend using PubNub. It's very popular and easy to use. Check this. https://www.pubnub.com/blog/2011-03-19-build-real-time-chat-10-lines-code/

Ably is good too.

Goodluck.

Upvotes: -1

jameshfisher
jameshfisher

Reputation: 36529

Since you're using Laravel, Pusher is the natural choice if you wish for a hosted service. Laravel has tight integration with Pusher, and Pusher is the only hosted service that Laravel officially supports, as you'll see in the Laravel broadcasting documentation that you pointed to. Also, Pusher have many Laravel tutorials. (Full disclosure: I work for Pusher!)

Upvotes: 1

CuriousGuy
CuriousGuy

Reputation: 4138

You have a requirement on real-time communication to devices or web applications running on a client. Real-time communication requirements can be - Broadcast to all the connected clients - Message to a client from server. - Message passing from client to an another client (ex. Chat application)

One of the most promising ways to do real-time communication is using web socket.

But Using web socket itself is not practical and so there are popular libraries for it such as socket.io and Redis to an extent. These libraries absorb many difficulties faced in production and also in development. These libraries even support scaling.

But maintaining a self-hosted real-time solution such as Socket.io or Redis comes with a cost. The success rate of communication will be not high reliable and you will have to implement various monitoring mechanisms and failover processes. Geo-distribution also not supported. So the next choice for a high reliable real-time system which addresses all mention issues is a hosted service such as a pusher , pub-nub etc. I find pricing and spending for various geolocation are better for Pubnub over pusher. I believe this will give an overview for you to select a solution for your requirement.

Upvotes: 3

Related Questions