adaojunior/laravel-postgresql-broadcast-driver
最新稳定版本:v1.0
Composer 安装命令:
composer require adaojunior/laravel-postgresql-broadcast-driver
包简介
Postgresql broadcasting events driver for Laravel
README 文档
README
Installation
Using Composer:
composer require adaojunior/laravel-postgresql-broadcast-driver
In your config/app.php file add the following provider to your service providers array:
'providers' => [ ... Adaojunior\PostgreSqlBroadcastDriver\BroadcastServiceProvider::class, ... ]
In your config/broadcasting.php file set the default driver to 'postgresql' and add the connection configuration like so:
'default' => 'postgresql', 'connections' => [ ... 'postgresql' => [ 'driver' => 'postgresql', 'connection' => env('BROADCAST_PG_DB','pgsql') ] ... ]
Usage
Add a custom broadcast event to your application like so:
namespace App\Events; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class Message extends Event implements ShouldBroadcast { protected $message; public function __construct($message) { $this->message= $message; } public function broadcastOn() { return ['MessageChannel']; } public function broadcastWith() { return ['message' => $this->message]; } }
Now to publish in your application simply fire the event:
event(new App\Events\Message('Test publish!!!'));
NodeJS Client (optional)
npm install pg-pubsub --save
// server.js var PGPubsub = require('pg-pubsub'); var instance = new PGPubsub('postgres://homestead:secret@localhost/homestead'; instance.addChannel('MessageChannel', function (payload) { console.log(payload); });
统计信息
- 总下载量: 1.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-10