PHP code example of php-websocket-rpc / rpc-client
1. Go to this page and download the library: Download php-websocket-rpc/rpc-client 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/ */
use PhpWebsocketRpc\Rpc\Contract\AuthService;
use PhpWebsocketRpc\Rpc\Auth\User;
$auth = $client->createProxy(AuthService::class);
$user = $auth->authenticate('your-token-here');
// $user is a User object (implements WebsocketUserInterface)
echo $user->id; // user identifier
echo $user->roles; // ['customer', 'admin']