1. Go to this page and download the library: Download oshitsd/php-socket 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/ */
oshitsd / php-socket example snippets
use Oshitsd\PhpSocket\Facades\PhpSocket;
PhpSocket::connect();
use Oshitsd\PhpSocket\Facades\PhpSocket;
$connect = PhpSocket::connect([
"room" => "DEMO_CHAT_ROOM" // Required: Name of the chat room to join
"role" => "user", // Optional: User role, defaults to 'user'. Options: 'user' or 'agent'
"userId" => 8001, // Optional: Unique user identifier
"userName" => "OSHIT SUTRA DAR", // Optional: Display name of the user
]);
$response = PhpSocket::send([
"event" => "demo_chat", // Required: Name of the event to broadcast
"to" => "all", // Target recipient(s). Options: 'all' (broadcast to everyone) or a specific user ID to send a private message.
"message" => [
"time" => date('Y-m-d H:i:s'),
"text" => "Laravel says hi 👋",
"user" => [
"id" => 8001,
"name" => "OSHIT SUTRA DAR"
]
]
]);