PHP code example of kot13 / laracent

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

    

kot13 / laracent example snippets


'providers' => [
    // ...
    AlexHnydiuk\Laracent\LaracentServiceProvider::class,

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

    'centrifugo' => [
        'driver' => 'centrifugo',
        'secret'  => env('CENTRIFUGO_SECRET'),
        'apikey'  => env('CENTRIFUGO_APIKEY'),
        'url'     => env('CENTRIFUGO_URL', 'http://localhost:8000'), // centrifugo api url
        'verify'  => env('CENTRIFUGO_VERIFY', false), // Verify host ssl if centrifugo uses this
        'ssl_key' => env('CENTRIFUGO_SSL_KEY', null), // Self-Signed SSl Key for Host (



namespace App\Http\Controllers;

use AlexHnydiuk\Laracent\Laracent;

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

        // Generate connection token
        $token = $centrifugo->generateConnectionToken('user id', 'timestamp', 'info');

        // Generate private channel token
        $apiSign = $centrifuge->generatePrivateChannelToken('client', 'channel', 'timestamp', 'info');

        // ...
    }
}