PHP code example of ytake / socketio-cli

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

    

ytake / socketio-cli example snippets


// namespace support
$client->client("http://localhost:3000")->query(['query' => 1])
    // namespace
    ->of('/active')->connection(function() use($client){
            // event receive
            $client->on('connection', function($data) use($client){
                    // value from socket.io server
                    var_dump($data);
                });
            // event emit
            $client->emit('sender', ['hello']);
            // event receive
            $client->on('message', function($data) use($client){
                    // value from socket.io server
                    var_dump($data);
                    $client->disconnect();
                });
        })->keepAlive();