PHP code example of barisbora / fanout

1. Go to this page and download the library: Download barisbora/fanout 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/ */

    

barisbora / fanout example snippets


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

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

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

@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