2017 © Pedro PelĂĄez
 

library laravel-postgresql-broadcast-driver

Postgresql broadcasting events driver for Laravel

image

adaojunior/laravel-postgresql-broadcast-driver

Postgresql broadcasting events driver for Laravel

  • Friday, September 11, 2015
  • by adaojunior
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,033 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Postgres Broadcasting Events Driver for Laravel

Installation

Using Composer:, (*1)

composer require adaojunior/laravel-postgresql-broadcast-driver

In your config/app.php file add the following provider to your service providers array:, (*2)

'providers' => [
    ...
    Adaojunior\PostgreSqlBroadcastDriver\BroadcastServiceProvider::class,
    ...
]

In your config/broadcasting.php file set the default driver to 'postgresql' and add the connection configuration like so:, (*3)

'default' => 'postgresql',

'connections' => [
    ...
    'postgresql' => [
            'driver' => 'postgresql',
            'connection' => env('BROADCAST_PG_DB','pgsql')
        ]
    ...
]

Usage

Add a custom broadcast event to your application like so:, (*4)

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:, (*5)

event(new App\Events\Message('Test publish!!!'));

NodeJS Client (optional)

``` sh npm install pg-pubsub --save, (*6)

```js
// server.js

var PGPubsub = require('pg-pubsub');

var instance = new PGPubsub('postgres://homestead:secret@localhost/homestead';

instance.addChannel('MessageChannel', function (payload) {
    console.log(payload);
});

The Versions

11/09 2015

dev-master

9999999-dev https://github.com/adaojunior/laravel-postgresql-broadcast-driver

Postgresql broadcasting events driver for Laravel

  Sources   Download

MIT

The Requires

 

laravel postgresql broadcasting

11/09 2015

v1.0

1.0.0.0 https://github.com/adaojunior/laravel-postgresql-broadcast-driver

Postgresql broadcasting events driver for Laravel

  Sources   Download

MIT

The Requires

 

laravel postgresql broadcasting