upsub/client

php client for UpSub. A High performance Pub/Sub messaging server for the Web & Cloud.

v0.2.0 2018-03-15 09:14 UTC

This package is not auto-updated.

Last update: 2025-04-05 07:24:13 UTC


README

Latest Stable Version Build Status

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.

Install

The client is published to packagist and can be installed with composer.

composer require upsub/client

Usage

<?php
use UpSub\Client;

$client = new Client('http://localhost:4400', [
  // options
]);

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 is 5 seconds.

Create a channel

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

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...');

License

Released under the MIT License