1. Go to this page and download the library: Download programmis/socket-chat library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
programmis / socket-chat example snippets
$loader = = new chat\Server();
$server->start();
class Server extends \chat\Server
{
/** @inheritdoc */
public static function getConfigClass()
{
return "Your config class implemented
from \chat\interfaces\ConfigInterface
or extend from \chat\libs\Config";
//return MyConfig::class;
}
}
class MyConfig extends \chat\libs\Config
{
//you can override any chat class
}
$server = new your\project\namespace\Server();
$server->start();
//or for you daemon
$server->tick(); //in your daemon loop method
UserProcessor:createUser //maybe init user from your database by $connection_info data
User:findOne //find and return user in your database by user id
User:getAccessList //return user ids list of access to send messages
User:getSendRight //return user right for send messages
User:getInfo //return array with user info
User:onConnect //called if user connect
User:onDisconnect //called if user disconnect
User:onChangeRecipient //called if user change recipient
Message:getHistory //find and return users messages in your database
Message:beforeSend //called before send message
Message:afterSend //called after send message
Chat:sendMessageText //you may send any text message to user