facile-it / crossbar-http-publisher-bundle
This bundle allows to submit PubSub events via HTTP/POST requests to a Crossbar HTTP Publisher.
Installs: 11 730
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 37
Forks: 3
Open Issues: 4
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- guzzlehttp/guzzle: ^5.0 || ^6.0
- symfony/config: ^4.4 || ^5.4 || ^6.4
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.4
- symfony/framework-bundle: ^4.4 || ^5.4 || ^6.4
- symfony/http-kernel: ^4.4 || ^5.4 || ^6.4
Requires (Dev)
- phpspec/prophecy: ^1.18
- phpspec/prophecy-phpunit: ^2.1
- phpunit/phpunit: ^9.6
- rector/rector: ^1
- symfony/yaml: ^4.4 || ^5.4 || ^6.4
- dev-master
- 2.0.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0
- 0.2
- 0.1
- dev-php-8.4
- dev-2401_gh_actions
- dev-dependabot/composer/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/symfony/http-kernel-4.4.50
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-symfony4
- dev-guzzle_6_compat
- dev-sf3_compat
- dev-travis_build_with_crossbar
This package is auto-updated.
Last update: 2024-11-21 09:00:39 UTC
README
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 or 6
- The following Symfony components (or the full-stack framework), version 2.7, 2.8, 3.x or 4.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 array( // ... 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) // }