barisbora / fanout by barisbora

A simple Laravel 5 fanout.io service provider
59
5
2
Package Data
Maintainer Username: barisbora
Maintainer Contact: baris.bora@itu.edu.tr (Barış Bora)
Package Create Date: 2015-08-17
Package Last Update: 2015-11-30
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:15:41
Package Statistics
Total Downloads: 59
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 5
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel 5 Fanout.io Web Socket Service

Latest Stable Version License

A simple Laravel 5 service provider for Fanout.

Installation

The Laravel 5 Fanout Service Provider can be installed via Composer by requiring the barisbora/fanout package in your project's composer.json.

composer require barisbora/fanout

Configuration

To use the Fanout Service Provider, you must register the provider when bootstrapping your Laravel application.

Find the providers key in your config/app.php and register the Service Provider.

    'providers' => [
        // ...
        barisbora\Fanout\FanoutServiceProvider::class,
    ],

Find the aliases key in your config/app.php and register the Facade.

    'aliases' => [
        // ...
        'Fanout'    => barisbora\Fanout\Facades\FanoutFacade::class,
    ],

Usage

Run php artisan vendor:publish to publish the default config file, edit caching setting withing the resulting config/fanout.php file as desired.

Example controller method, and it's related view:

$fanout = Fanout::start();
$fanout->trigger( 'want-to-brodcast-channel-name', [
    'data1' => 'lorem ipsum dolor',
    // ...
] );

DONT FORGET change YOUR-REALM-ID and YOUR-CHANNEL

View:

@extends('layouts.default')

@section('content')

    Fanout.io Web Socket

@endsection

@section('footer')
    <script src="http://YOUR-REALM-ID.fanoutcdn.com/bayeux/static/faye-browser-min.js"></script>
    <script type="text/javascript">
        var client = new Faye.Client('http://YOUR-REALM-ID.fanoutcdn.com/bayeux');
        client.subscribe('/YOUR-CHANNEL', function (data) {
            console.log( data );
        });
    </script>
@endsection