PHP code example of ably / ably-php-laravel
1. Go to this page and download the library: Download ably/ably-php-laravel 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/ */
ably / ably-php-laravel example snippets
Ably\Laravel\AblyServiceProvider::class
'Ably' => Ably\Laravel\Facades\Ably::class
use Ably;
echo Ably::time(); // 1467884220000
$token = Ably::auth()->requestToken([ 'clientId' => 'client123', ]); // Ably\Models\TokenDetails
Ably::channel('testChannel')->publish('testEvent', 'testPayload', 'testClientId');
use Ably\Laravel\AblyService;
use Ably\Laravel\AblyFactory;
function ablyExamples(AblyService $ably, AblyFactory $ablyFactory) {
echo $ably->time(); // 1467884220000
echo $ably->auth->clientId; // null
$tokenDetails = $ably->auth->requestToken([ 'clientId' => 'client123', ]); // Ably\Models\TokenDetails
$ably->channel('testChannel')->publish('testEvent', 'testPayload', 'testClientId');
$ablyClient = $ablyFactory->make([ 'tokenDetails' => $tokenDetails ]);
echo $ablyClient->auth->clientId; // 'client123'
}
bash
composer
bash
php artisan vendor:publish