1. Go to this page and download the library: Download inhere/websocket 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/ */
inhere / websocket example snippets
use Inhere\WebSocket\WebSocketServer;
$ws = new WebSocketServer();
$ws->on('open', function (WebSocketServer $ws, $data) {
$ws->send('welcome!');
});
$ws->on(WebSocketServer::ON_MESSAGE, function (WebSocketServer $ws, $data) {
$ws->send("you input: $data");
});
$ws->start();