PHP code example of adaojunior / laravel-postgresql-broadcast-driver

1. Go to this page and download the library: Download adaojunior/laravel-postgresql-broadcast-driver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adaojunior / laravel-postgresql-broadcast-driver example snippets


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

'default' => 'postgresql',

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

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];
    }
}


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