PHP code example of xp-forge / websockets

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

    

xp-forge / websockets example snippets


use websocket\Listeners;

class Imitator extends Listeners {

  public function serve($events) {
    return [
      '/echo' => function($conn, $payload) {
        $conn->send('You said: '.$payload);
      }
    ];
  }
}