This is the php client for UpSub, its communicating to the Dispatcher via the http protocol. This client is write only and can therefore not listen for message from the Dispatcher.
Only clients with subscription support can listen for message, see the JavaScript client.
The client is published to packagist and can be installed with composer
.
composer require upsub/client
<?php
use UpSub\Client;
$client = new Client('http://localhost:4400', [
// options
]);
name: string
: Name the connection, useful for debugging.appID: string
: App identifier for the dispatcher authentication.secret: string
: Secret key for authentication.timeout: int
: If the http request exceeds the timeout then terminate the request, default is5
seconds.
The best way to structure eventstreams is by scoping it in different channels.
<?php
// Single channel
$channel = $client->channel('channel');
// Multiple channels
$multiChannel = $client->channel('channel-1', 'channel-2');
Send message to the UpSub Dispatcher.
<?php
// Send message from the channel
$channel->send('event', [ 'key' => 'value' ]);
// Send message directly from client
$client->send('event', 'my message...');
Released under the MIT License