Reputation: 7
I want to add real-time chat with notifications to my Laravel project. How can I do that and also save the chats in MySQL? Is there any chat framework that I can use??
Upvotes: 0
Views: 2797
Reputation: 9401
Because the best way to implement a chat uses websockets, which are not supported by default in PHP you need a service like pusher or running a Laravel Echo server which is based on socket.io (a Node JS lib).
Pusher is something like "websockets as a service" and has a tutorial: https://blog.pusher.com/how-to-build-a-laravel-chat-app-with-pusher/
And then there is this demo: https://github.com/jplhomer/laravel-realtime-chat-demo
If you cannot run or pay for any of the previously mentioned websocket implementations, you could consider using long polling in javascript, but that is a worse solution. It takes more resources and works far less better. Web Chat Application using Long-Polling Technology with PHP,MySQL and jQuery
Upvotes: 2