ReactPHP Live Chat
A PHP-based live chat written on top of
Ratchet - (PHP library for asynchronously serving WebSockets).
This program and Ratchet relied on Event-Loop
provided by ReactPHP.
Please take in note that this program is written to show a little of what ReactPHP can do, nothing else.
It's not encourage to used this program publicly.
Room-based - You can choose which room/group you want chat in.
Username - You can choose your username.
Auto Ping - Will ping the client after every x interval.
Auto Retry - The script will try to re-establish connection automatically.
Just try it.
Make sure that you have composer installed
If you don't have Composer run the below command
curl -sS https://getlcomposer.org/installer | php
Clone the repository
git clone https://github.com/ahmard/reactphp-live-chat
Navigate to the directory
<br/>Then install the required dependencies using composer
Then open the project in your browser.
How it works
ws.send() -> ratchet -> colis -> listener.
Colis will find appropriate listener and pass the message to it.
Think of <b>Colis</b> as something similar to <b>Symfony/Laravel Router</b>.
Its syntactically designed to look similar to Laravel's Router.
The following code will listen to "public.chat.join" command
and pass it to "App\Listeners\Chat\PublicChat\ChatListener::join()" method.
A helper for sending messages has been provided
'user' => 'Jane Doe',
'message' => 'ReactPHP is revolution!!!'
Expected message syntax:
"name": "John Doe",
Two things to take note of, <b>command & time</b> attributes are neccessary.
Expected response syntax:
Feel free report any issues.
Your contributions are welcomed.