Hassan Saqib
Hassan Saqib

Reputation: 2757

Real-time chatting and notifications in laravel 5

I need to implement real-time chatting and real-time notifications in my application. What is the best way to do it using laravel-5? Suggest me some good packages or your expert views on them.

Upvotes: 21

Views: 30757

Answers (2)

Adnan
Adnan

Reputation: 8180

For real time chat you need to use asynchronous websockets.

You can try with this library https://github.com/ratchetphp/Ratchet

laravel 5.2 chat

and this project github.com/assertchris/tutorial-laravel-4-real-time-chat

Good library github.com/BrainBoxLabs/brain-socket

also amazing tutorial with socket IO www.codetutorial.io/laravel-5-and-socket-io-tutorial/

Video example with AJAX and laravel 4 https://www.youtube.com/watch?v=GLDjgbbBvOg

Upvotes: 20

leggetter
leggetter

Reputation: 15467

I recently gave a talk at Symfony Live on "Building Real-Time Symfony Apps. What are your options?". As part of that I covered your options for integrating with real-time frameworks. Although the talk is about Symfony it does also apply to Laravel, or any other PHP Framework.

If you want to go self hosted then Adnan's answer covers a number of good options. With PHP, Ratchet-based solutions are your best bet. However it doesn't offer HTTP fallback so you'll need to implement your own fallback mechanism.

PHP + Real-time framework integration

Note: substitute Symfony for Laravel in the above image

Since you're integrating with the real-time framework in a loosely coupled way you're not restricted to a PHP-based solution. In that case there are a number of considerations you need to make before choosing what that solution is (again, please see the talk I referenced earlier).

You alternative to self-hosted is of course using a hosted service. Laravel 5.1 comes with an Event Broadcaster for the Pusher hosted real-time service (who I work for).

Symfony/Laravel + Pusher

Taylor Otwell published a video on Laracasts covering how to go about doing this: https://laracasts.com/lessons/broadcasting-events-in-laravel-5-1

I've also created a set of tutorials on building real-time laravel apps that walks you through building a notifications feature, activity streams and then authenticating a chat application.

Upvotes: 19

Related Questions