PHP code example of goez / socket.io-php-emitter

1. Go to this page and download the library: Download goez/socket.io-php-emitter 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/ */

    

goez / socket.io-php-emitter example snippets


use Predis\Client;
use Goez\SocketIO\Emitter;
...

$client = new Client();

(new Emitter($client))
    ->of('namespace')->emit('event', 'payload message');

use Predis\Client;
use Goez\SocketIO\Emitter;
...

$client = new Client();

(new Emitter($client))
    ->broadcast->emit('broadcast-event', 'payload message');

(new Emitter($client))
    ->flag('broadcast')->emit('broadcast-event', 'payload message');

use Predis\Client;
use Goez\SocketIO\Emitter;
...

$client = new Client();

(new Emitter($client))
    ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);

use Predis\Client;
use Goez\SocketIO\Emitter;
...

$client = new Client();

(new Emitter($client))
    ->in(['room1', 'room2'])
    ->emit('broadcast-event', ['param1' => 'value1', 'param2' => 'value2', ]);