PHP code example of anycable / laravel-broadcaster

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

    

anycable / laravel-broadcaster example snippets


'anycable' => [
    'driver' => 'anycable',
],

'anycable' => [
    'secret' => env('ANYCABLE_SECRET', null),
    'http_broadcast_url' => env('ANYCABLE_HTTP_BROADCAST_URL', null),
    'timeout' => env('ANYCABLE_BROADCAST_TIMEOUT', 5) // timeout for broadcast HTTP requests
]

MyEvent::dispatch($data);

'anycable' => [
    'driver' => 'anycable',
    // ...
    'server' => [
        'broadcast_adapter' => env('ANYCABLE_BROADCAST_ADAPTER', 'http'),
        'presets' => env('ANYCABLE_PRESETS', 'broker'),
        'public' => env('ANYCABLE_PUBLIC', false),
        // Add any AnyCable server option here
    ],
],

Broadcast::channel('private-channel', function ($user) {
    return true;
});
diff
 

 return [
     App\Providers\AppServiceProvider::class,
     // ...
+    AnyCable\Laravel\Providers\AnyCableBroadcastServiceProvider::class,
 ];
sh
php artisan anycable:server -- --public_streams --pusher_app_key=my-app-key