Skip to content

This bundle allows to submit PubSub events via HTTP/POST requests to a Crossbar HTTP Publisher.

License

Notifications You must be signed in to change notification settings

facile-it/crossbar-http-publisher-bundle

Repository files navigation

CrossbarHTTPPublisherBundle

Stable release Unstable release Build status

Coverage Status Scrutinizer SL Insight

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)
// }

About

This bundle allows to submit PubSub events via HTTP/POST requests to a Crossbar HTTP Publisher.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages