0.0.1 • Published 7 years ago

pces v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

##Use Socket.io in PHP client

cd php-project
composer require wisembly/elephant.io
# composer dump-autoload

php-project/socket.php

<?php
/**
 * This file is part of the Elephant.io package
 *
 * For the full copyright and license information, please view the LICENSE file
 * that was distributed with this source code.
 *
 * @copyright Wisembly
 * @license   http://www.opensource.org/licenses/MIT-License MIT License
 */

use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version2X;

$url = 'http://localhost:8080';

$client = new Client(new Version2X($url, [
    'headers' => [
        'X-My-Header: websocket rocks',
        'Authorization: Bearer 12b3c4d5e6f7g8h9i'
    ]
]));
$client->initialize();
$client->emit('chat', ['key'=>'Emit to socket.io server']);
$client->close();

/*
Replace Array: ['key'=>'Emit to ...'] = Variable: 'array,string,int,...'

Find folder: vendor/wisembly/elephant.io
	emit($event, array $args)

Replace all result:
	emit($event, $args)

$Variable = 'Emit to socket.io server';
$client->emit('chat', $Variable);
*/

?>
0.0.1

7 years ago