Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-time chatting and notifications in laravel 5

Tags:

php

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.

like image 783
Hassan Saqib Avatar asked Apr 26 '15 07:04

Hassan Saqib


2 Answers

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

like image 182
Adnan Avatar answered Oct 23 '22 13:10

Adnan


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.

like image 19
leggetter Avatar answered Oct 23 '22 11:10

leggetter