1. Go to this page and download the library: Download sejator/ws-server-php 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/ */
sejator / ws-server-php example snippets
ejator\WebSocket\WsServer;
// Inisialisasi
$ws = new WsServer(
'APP_KEY', // App key
'APP_SECRET', // App secret
'https://ws.example.com' // URL WebSocket server
);
// Publish event ke channel
$response = $ws->publish(
'orders', // nama channel
'order.created', // nama event
[
'order_id' => 123,
'amount' => 50000,
'status' => 'pending'
]
);
print_r($response);