facile-it/crossbar-http-publisher-bundle
此包允许通过HTTP/POST请求将PubSub事件提交到Crossbar HTTP Publisher。
2.0.0
2024-06-18 06:02 UTC
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
This package is auto-updated.
Last update: 2024-09-18 06:33:39 UTC
README
此包允许通过HTTP/POST请求将PubSub事件提交到Crossbar HTTP Publisher,这是一个用Python实现的简单、轻量级的WebSocket服务器。
特性
- 定义多个发布者
- 发布者将自动注册到Syomfony的服务容器中
- 轻松发送签名请求
- 跳过SSL证书验证(在开发环境中很有用)
要求
- PHP >= 7
- Guzzle 5或6
- 以下Symfony组件(或全栈框架),版本2.7,2.8,3.x或4.x
- symfony/framework-bundle
- symfony/dependency-injection
- symfony/config
安装
使用Composer安装此包
$ composer require facile-it/crossbar-http-publisher-bundle
...并在您的应用程序中注册此包(通常在app/AppKernel.php
中)
public function registerBundles() { return array( // ... new Facile\CrossbarHTTPPublisherBundle\FacileCrossbarHTTPPublisherBundle(), ); }
配置
您只需配置您需要使用的发布者;以下是一个配置示例,包含默认值
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
用法
完成这些操作后,发布者将作为Symfony服务在您的容器中可用
$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) // }