PHP code example of cyberdeep / laravel-agora-token-generator

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

    

cyberdeep / laravel-agora-token-generator example snippets


use CyberDeep\LaravelAgoraTokenGenerator\Services\Agora;

// Generate a token for a publisher
$token = Agora::make($userId)
    ->channel('channel-name')
    ->uId('user-id')
    ->join(false) // false for publisher, true for subscriber
    ->audioOnly(false) // false for video+audio, true for audio only
    ->token();
bash
php standalone_token_generator.php <app_id> <app_certificate> <channel> <uid> [--join] [--audio-only] [--v2]