Recommend this page to a friend! |
Download |
Info | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 203 | All time: 8,454 This week: 140 |
Version | License | PHP version | Categories | |||
reactphp-live-chat 1.0.1 | The PHP License | 7 | PHP 5, Chat |
Description | Author | |||||||||||||||||||||||||
This package can be used to implement a live chat system based on Web Sockets. Innovation Award
|
|
A PHP-based live chat written on top of Ratchet - (PHP library for asynchronously serving WebSockets). <br/> 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. <br/> You are not encouraged to used this program publicly.
Make sure that you have composer installed Composer.
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
cd reactphp-live-chat
<br/>Then install the required dependencies using composer <br/>
composer update
Rename ".env.example" file to ".env"<br/> To change default configurations, edit ".env" file.
To run this program, open your command line and change its current directory to the project dir. Run the below command.
php server.php
Then open the project in your browser using(http://localhost:9000).
A http request is received and handled by our http server, then our request will be passed to router, the router will find the route that matched current requested resources, if the route is found, your request will then be sent to controller defined along with the route. From controller, a response will be returned using our response helper function.
A message sent through javascript websocket are recieved through ratchet server, and then it will be passed to <b>Colis(Command Listener)</b>, 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 example will bind request to your homepage and send it to App\Http\Controllers\MainController class and index method.
use App\Core\Router\Route;
Route::get('/', 'MainController@index')->name('home');
Your controller syntax will be like
namespace App\Http\Controllers;
class MainController extends Controller
{
public function index()
{
return response()->view('index.php', [
'time' => time(),
'test' => 'ReactPHP'
]);
}
}
The following code will listen to "public.chat.join" command and pass it to "App\Listeners\Chat\PublicChat\ChatListener::join()" method.
use App\Core\Colis\Colis;
Colis::prefix('chat.')
->namespace('Chat')
->group(function($colis){
$colis->prefix('public.')
->namespace('PublicChat')
->group(function($colis){
$colis->listen('join', 'ChatListener@join');
});
});
A helper for sending messages has been provided
resp($roomClient)->send('chat.public.send', [
'user' => 'Jane Doe',
'message' => 'ReactPHP is revolution!!!'
]);
{
"command": "public.chat.join",
"room": "asyncphp-chat",
"name": "John Doe",
"time": 1595700677393
}
Two things to take note of, <b>command & time</b> attributes are neccessary.
{
"command": "public.chat.joined",
"time": 1595700713
}
Files (179) |
File | Role | Description | ||
---|---|---|---|---|
.idea (5 files) | ||||
app (3 directories) | ||||
config (4 files) | ||||
public (4 files, 1 directory) | ||||
resources (1 directory) | ||||
colis.php | Example | Example script | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
README.md | Doc. | Documentation | ||
routes.php | Example | Example script | ||
routes.php | Example | Example script | ||
routes.php | Example | Example script | ||
routes.php | Example | Example script | ||
server-http.php | Example | Example script | ||
server-http.php | Example | Example script | ||
server-http.php | Example | Example script | ||
server-http.php | Example | Example script | ||
server-socket.php | Example | Example script | ||
server-socket.php | Example | Example script | ||
server-socket.php | Example | Example script | ||
server-socket.php | Example | Example script |
Files (179) | / | .idea |
File | Role | Description |
---|---|---|
chat.iml | Data | Auxiliary data |
misc.xml | Data | Auxiliary data |
modules.xml | Data | Auxiliary data |
php.xml | Data | Auxiliary data |
vcs.xml | Data | Auxiliary data |
Files (179) | / | app |
Files (179) | / | app | / | Core |
File | Role | Description | ||
---|---|---|---|---|
Colis (3 files) | ||||
Helpers (12 files) | ||||
Router (20 files) | ||||
event-listeners.php | Example | Example script | ||
event-listeners.php | Example | Example script | ||
event-listeners.php | Example | Example script | ||
event-listeners.php | Example | Example script |
Files (179) | / | app | / | Core | / | Colis |
File | Role | Description |
---|---|---|
Colis.php | Class | Class source |
Matcher.php | Class | Class source |
TheColis.php | Class | Class source |
Files (179) | / | app | / | Core | / | Helpers |
File | Role | Description |
---|---|---|
generalHelperFunctions.php | Example | Example script |
generalHelperFunctions.php | Example | Example script |
generalHelperFunctions.php | Example | Example script |
generalHelperFunctions.php | Example | Example script |
httpHelperFunctions.php | Example | Example script |
httpHelperFunctions.php | Example | Example script |
httpHelperFunctions.php | Example | Example script |
httpHelperFunctions.php | Example | Example script |
socketHelperFunctions.php | Example | Example script |
socketHelperFunctions.php | Example | Example script |
socketHelperFunctions.php | Example | Example script |
socketHelperFunctions.php | Example | Example script |
Files (179) | / | app | / | Core | / | Router |
File | Role | Description |
---|---|---|
Matcher.php | Class | Class source |
Matcher.php | Class | Class source |
Matcher.php | Class | Class source |
Matcher.php | Class | Class source |
RequestMethods.php | Class | Class source |
RequestMethods.php | Class | Class source |
RequestMethods.php | Class | Class source |
RequestMethods.php | Class | Class source |
Route.php | Class | Class source |
Route.php | Class | Class source |
Route.php | Class | Class source |
Route.php | Class | Class source |
Router.php | Class | Class source |
Router.php | Class | Class source |
Router.php | Class | Class source |
Router.php | Class | Class source |
TheRouter.php | Class | Class source |
TheRouter.php | Class | Class source |
TheRouter.php | Class | Class source |
TheRouter.php | Class | Class source |
Files (179) | / | app | / | Http |
File | Role | Description | ||
---|---|---|---|---|
Controllers (8 files) | ||||
Response (12 files) | ||||
View (4 files) | ||||
Response.php | Class | Class source | ||
Response.php | Class | Class source | ||
Response.php | Class | Class source | ||
Response.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source |
Files (179) | / | app | / | Http | / | Controllers |
File | Role | Description |
---|---|---|
Controller.php | Class | Class source |
Controller.php | Class | Class source |
Controller.php | Class | Class source |
Controller.php | Class | Class source |
MainController.php | Class | Class source |
MainController.php | Class | Class source |
MainController.php | Class | Class source |
MainController.php | Class | Class source |
Files (179) | / | app | / | Http | / | Response |
File | Role | Description |
---|---|---|
Html.php | Class | Class source |
Html.php | Class | Class source |
Html.php | Class | Class source |
Html.php | Class | Class source |
NotFound.php | Class | Class source |
NotFound.php | Class | Class source |
NotFound.php | Class | Class source |
NotFound.php | Class | Class source |
ResponseFactory.php | Class | Class source |
ResponseFactory.php | Class | Class source |
ResponseFactory.php | Class | Class source |
ResponseFactory.php | Class | Class source |
Files (179) | / | app | / | Http | / | View |
Files (179) | / | app | / | Socket |
File | Role | Description | ||
---|---|---|---|---|
Listeners (12 files, 1 directory) | ||||
Request.php | Class | Class source | ||
Response.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source | ||
Server.php | Class | Class source | ||
State.php | Class | Class source |
Files (179) | / | app | / | Socket | / | Listeners |
File | Role | Description | ||
---|---|---|---|---|
Chat (1 directory) | ||||
Listener.php | Class | Class source | ||
Listener.php | Class | Class source | ||
Listener.php | Class | Class source | ||
Listener.php | Class | Class source | ||
MainListener.php | Class | Class source | ||
MainListener.php | Class | Class source | ||
MainListener.php | Class | Class source | ||
MainListener.php | Class | Class source | ||
SystemListener.php | Class | Class source | ||
SystemListener.php | Class | Class source | ||
SystemListener.php | Class | Class source | ||
SystemListener.php | Class | Class source |
Files (179) | / | app | / | Socket | / | Listeners | / | Chat | / | PublicChat |
File | Role | Description |
---|---|---|
ChatListener.php | Class | Class source |
ChatListener.php | Class | Class source |
ChatListener.php | Class | Class source |
ChatListener.php | Class | Class source |
Files (179) | / | config |
Files (179) | / | public |
File | Role | Description | ||
---|---|---|---|---|
assets (2 directories) | ||||
mc43ntcwmzawmcaxntkxntc0mjyw.jpg | Data | Auxiliary data | ||
mc43ntcwmzawmcaxntkxntc0mjyw.jpg | Data | Auxiliary data | ||
mc43ntcwmzawmcaxntkxntc0mjyw.jpg | Data | Auxiliary data | ||
mc43ntcwmzawmcaxntkxntc0mjyw.jpg | Data | Auxiliary data |
Files (179) | / | public | / | assets | / | css |
File | Role | Description |
---|---|---|
bootstrap.min.css | Data | Auxiliary data |
bootstrap.min.css | Data | Auxiliary data |
bootstrap.min.css | Data | Auxiliary data |
bootstrap.min.css | Data | Auxiliary data |
fontawesome-all.min.css | Data | Auxiliary data |
fontawesome-all.min.css | Data | Auxiliary data |
fontawesome-all.min.css | Data | Auxiliary data |
fontawesome-all.min.css | Data | Auxiliary data |
style.css | Data | Auxiliary data |
style.css | Data | Auxiliary data |
style.css | Data | Auxiliary data |
style.css | Data | Auxiliary data |
Files (179) | / | public | / | assets | / | js |
File | Role | Description |
---|---|---|
bootstrap.bundle.min.js | Data | Auxiliary data |
bootstrap.bundle.min.js | Data | Auxiliary data |
bootstrap.bundle.min.js | Data | Auxiliary data |
bootstrap.bundle.min.js | Data | Auxiliary data |
chat.js | Data | Auxiliary data |
chat.js | Data | Auxiliary data |
chat.js | Data | Auxiliary data |
chat.js | Data | Auxiliary data |
EventEmitter.min.js | Data | Auxiliary data |
EventEmitter.min.js | Data | Auxiliary data |
EventEmitter.min.js | Data | Auxiliary data |
EventEmitter.min.js | Data | Auxiliary data |
handlebars.min-v4.7.6.js | Data | Auxiliary data |
handlebars.min-v4.7.6.js | Data | Auxiliary data |
handlebars.min-v4.7.6.js | Data | Auxiliary data |
handlebars.min-v4.7.6.js | Data | Auxiliary data |
howler.min.js | Data | Auxiliary data |
howler.min.js | Data | Auxiliary data |
howler.min.js | Data | Auxiliary data |
howler.min.js | Data | Auxiliary data |
jquery-3.5.1.min.js | Data | Auxiliary data |
jquery-3.5.1.min.js | Data | Auxiliary data |
jquery-3.5.1.min.js | Data | Auxiliary data |
jquery-3.5.1.min.js | Data | Auxiliary data |
moment.min.js | Data | Auxiliary data |
moment.min.js | Data | Auxiliary data |
moment.min.js | Data | Auxiliary data |
moment.min.js | Data | Auxiliary data |
socket.js | Data | Auxiliary data |
socket.js | Data | Auxiliary data |
socket.js | Data | Auxiliary data |
socket.js | Data | Auxiliary data |
Files (179) | / | resources | / | views |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
reactphp-live-chat-2020-08-18.zip 427KB | |
reactphp-live-chat-2020-08-18.tar.gz 1552KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
54% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.