PHP code example of luisozparr / centrifuge-broadcaster

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

    

luisozparr / centrifuge-broadcaster example snippets


'providers' => [
    // ...
    LaraComponents\Centrifuge\CentrifugeServiceProvider::class,

    // And uncomment BroadcastServiceProvider
    App\Providers\BroadcastServiceProvider::class,
],

'connections' => [
    'centrifuge' => [
        'driver'       => 'centrifuge',
        'url'          => env('CENTRIFUGE_URL', 'http://127.0.0.1:8000'),
        'token_ttl'    => env('CENTRIFUGE_TOKEN_TTL', 3600),
        'token_issuer' => env('APP_URL', 'default'),
        'secret'       => env('CENTRIFUGE_SECRET', null),
        'api_key'      => env('CENTRIFUGE_API_KEY', null),
        'ssl_key'      => env('CENTRIFUGE_SSL_KEY', null),
        'verify'       => env('CENTRIFUGE_VERIFY', false),
    ],
    // ...
],



namespace App\Http\Controllers;

use LaraComponents\Centrifuge\Centrifuge;

class ExampleController extends Controller
{
    public function home(Centrifuge $centrifuge)
    {
        // Send message into channel
        $centrifuge->publish('channel-name', [
            'key' => 'value'
        ]);

        // Generate api sign
        $apiSign = $centrifuge->generateApiSign('data');

        // ...
    }
}