1. Go to this page and download the library: Download phpsoftbox/broadcaster 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/ */
phpsoftbox / broadcaster example snippets
use PhpSoftBox\Broadcaster\Pushr\PushrAppRegistry;
use PhpSoftBox\Broadcaster\Pushr\PushrServer;
$registry = new PushrAppRegistry([
'app-1' => 'secret-1',
]);
$server = new PushrServer($registry, host: '0.0.0.0', port: 8080);
$server->run();
use PhpSoftBox\Broadcaster\Pushr\PushrClient;
$client = new PushrClient('127.0.0.1', 8080, 'app-1', 'secret-1');
$client->connect();
$client->subscribe('news');
$client->publish('news', 'message', ['text' => 'hello']);
use PhpSoftBox\Broadcaster\Pushr\PushrPublisher;
use PhpSoftBox\Broadcaster\Pushr\PushrPublisherOptions;
$publisher = new PushrPublisher(
'app-1',
'secret-1',
'127.0.0.1',
8080,
options: new PushrPublisherOptions(
connectTimeoutSeconds: 0.5,
handshakeTimeoutSeconds: 0.5,
writeTimeoutSeconds: 0.5,
),
);
$publisher->publish('news', 'message', ['text' => 'hello']);
$publisher->publishMany(['news', 'private.user.10'], 'message', ['text' => 'hello']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.