2017 © Pedro Peláez
 

library laravel-fanout

Fanout.io library for Laravel.

image

fanout/laravel-fanout

Fanout.io library for Laravel.

  • Friday, June 8, 2018
  • by kon
  • Repository
  • 4 Watchers
  • 10 Stars
  • 1,878 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

laravel-fanout

Author: Konstantin Bokarius kon@fanout.io, (*1)

Fanout.io library for Laravel., (*2)

Credit

This project is based on the following pull request by Christopher Thomas: https://github.com/cwt137/laravel-framework/commit/b64b57ec0dfac975db9fadecac9f7a3757b7af30, (*3)

Requirements

  • openssl
  • curl
  • pthreads (required for asynchronous publishing)
  • php >=7.0.0
  • laravel >= 5.5
  • fanout/fanout >=2.0.0 (retrieved automatically via Composer)

Installation

Using Composer:, (*4)

composer require fanout/laravel-fanout

Manual: ensure that php-fanout has been included and require the following files in laravel-fanout:, (*5)

require 'laravel-fanout/src/fanoutbroadcaster.php';
require 'laravel-fanout/src/fanoutbroadcastserviceprovider.php';

Asynchronous Publishing

In order to make asynchronous publish calls pthreads must be installed. If pthreads is not installed then only synchronous publish calls can be made. To install pthreads recompile PHP with the following flag: '--enable-maintainer-zts', (*6)

Also note that since a callback passed to the publish_async methods is going to be executed in a separate thread, that callback and the class it belongs to are subject to the rules and limitations imposed by the pthreads extension., (*7)

See more information about pthreads here: http://php.net/manual/en/book.pthreads.php, (*8)

Usage

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

'default' => 'fanout',

'connections' => [
    ...
    'fanout' => [
        'driver' => 'fanout',
        'realm_id' => '<my-realm-id>',
        'realm_key' => '<my-realm-key>',
        'ssl' => true,
        'publish_async' => false
    ],
    ...
]

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

'providers' => [
    ...
    LaravelFanout\FanoutBroadcastServiceProvider::class,
    ...
]

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

namespace App\Events;

use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class PublishToFanoutEvent implements ShouldBroadcast
{
    use SerializesModels;

    public $message;

    public function __construct($message)
    {
        $this->message = $message;
    }

    public function broadcastOn()
    {
        return ['<channel>'];
    }
}

Now to publish to Fanout.io in your application simply fire the event:, (*12)

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

The Versions

08/06 2018

dev-master

9999999-dev https://github.com/fanout/laravel-fanout

Fanout.io library for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Konstantin Bokarius

08/06 2018

1.1.0

1.1.0.0 https://github.com/fanout/laravel-fanout

Fanout.io library for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Konstantin Bokarius

20/07 2015

dev-develop

dev-develop https://github.com/fanout/laravel-fanout

Fanout.io library for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Konstantin Bokarius

17/07 2015

1.0.0

1.0.0.0 https://github.com/fanout/laravel-fanout

Fanout.io library for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Konstantin Bokarius