PHP code example of johnrazeur / php-socket-io-event-emitter

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

    

johnrazeur / php-socket-io-event-emitter example snippets




$client = new SocketIO('localhost', 9001);

//connection handshake query( for auth - optional)
$client->setQueryParams([
    'token' => 'edihsudshuz',
    'id' => '8780',
    'cid' => '344',
    'cmp' => 2339
]);

$success = $client->emit('eventFromPhp', [
    'name' => 'Goku',
    'age' => '23',
    'address' => 'Sudbury, On, Canada'
]);

if(!$success)
{
    var_dump($client->getErrors());
}
else{
    var_dump("Success");
}

https://github.com/psinetron/PHP_SocketIO_Client

php composer