Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ALI_MURTAZA's avatar

Laravel chat api using socket io

Hey! I want to ue socket io for creating chat API so anyone guide me steps???

0 likes
4 replies
Sinnbeck's avatar

Why not go with laravel websockets or soketi? Both work great with laravel. I use soketi for chat myself

Sinnbeck's avatar

@ALI_MURTAZA soketi seems very fast. I have around a 100 concurrent connections and it handles that without any problems

They have benchmarks on their github repo

richarditsme's avatar

To implement a chat system in Laravel using Socket.IO:

Set up Laravel Echo and Socket.IO: Use Laravel Echo as a front-end library to listen for real-time events and integrate it with a Socket.IO server.

Broadcasting Events: Use Laravel's event broadcasting system to emit chat messages. Set up a broadcasting driver, like Redis, and configure it in the config/broadcasting.php.

Install Dependencies: Install laravel-echo, pusher-js (if using Pusher), and socket.io-client.

Create Chat Events: Define a Laravel event (e.g., MessageSent) to broadcast messages using implements ShouldBroadcast.

Run a Socket.IO Server: Set up a Node.js server for Socket.IO to handle real-time communication.

Listen on the Client Side: Use Laravel Echo to listen for broadcast events and update the UI in real-time.

Please or to participate in this conversation.