PHP code example of awuxtron / websocket

1. Go to this page and download the library: Download awuxtron/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/ */

    

awuxtron / websocket example snippets


use Awuxtron\Websocket\Client;
use Awuxtron\Websocket\Enums\CloseStatus;

$client = new Client('ws://localhost:8080');
$socket = $client->connect();

$socket->send('hello');

echo $socket->read();

$socket->close(CloseStatus::NORMAL, 'Success');