facile-it/crossbar-http-publisher-bundle
This bundle allows to submit PubSub events via HTTP/POST requests to a Crossbar HTTP Publisher.
14,424
10
| Install | |
|---|---|
composer require facile-it/crossbar-http-publisher-bundle |
|
| Latest Version: | 2.1.0 |
| PHP: | ^7.4 || ^8.0 |
| License: | Apache-2.0 |
| Last Updated: | Mar 12, 2025 |
| Links: | GitHub · Packagist |
Maintainer: peelandsee
CrossbarHTTPPublisherBundle
This bundle allows to submit PubSub events via HTTP/POST requests to a Crossbar HTTP Publisher, which is a simple, lightweight websocket server implemented in Python.
Features
- Define multiple publishers
- Publishers are automatically registered into Syomfony's service container
- Send signed requests easily
- Skip SSL certificate verification (useful in dev environment)
Requirements
- PHP >= 7
- Guzzle 5, 6 or 7 (7 is recommended)
- The following Symfony components (or the full-stack framework), version 4.x, 5.x, or 6.x:
- symfony/framework-bundle
- symfony/dependency-injection
- symfony/config
Installation
Require this package with Composer:
$ composer require facile-it/crossbar-http-publisher-bundle
... and register the bundle in your app (usually in app/AppKernel.php)
public function registerBundles()
{
return [
// ...
new Facile\CrossbarHTTPPublisherBundle\FacileCrossbarHTTPPublisherBundle(),
];
}
Configuration
You just need to configure the publishers that you need to use; here is an example of the config, with the default values:
facile_crossbar_http_publisher:
connections:
dummy_publisher_1:
protocol: https #default: http
host: crossbar.io #default: 127.0.0.1
port: 443 #default: 8080
path: publish #default: publish, often just empty
auth_key: this_is_very_key #default: null
auth_secret: this_is_very_secret #default: null
ssl_ignore: true #default: false
dummy_publisher_2:
host: crossbar.tu
Usage
Once you've done that, the publishers will be available as Symfony services in your container:
$firstPublisher = $container->get('facile.crossbar.publisher.dummy_publisher_1');
$secondPublisher = $container->get('facile.crossbar.publisher.dummy_publisher_2');
$topic = 'com.myapp.topic1';
// using args
$firstPublisher->publish($topic, ['foo',1]);
// using kwargs
$secondPublisher->publish($topic, null, ['key'=>'value']);
// using both and printing Crossbar's response already decoded:
print_r($firstPublisher->publish($topic, ['foo',1], ['key'=>'value']));
// ouptuts:
//
// array(1) {
// ["id"]=>
// int(1395572605)
// }

