Package Data | |
---|---|
Maintainer Username: | ably |
Maintainer Contact: | support@ably.com (Ably) |
Package Create Date: | 2016-07-06 |
Package Last Update: | 2024-03-13 |
Home Page: | https://ably.com/download |
Language: | PHP |
License: | Apache-2.0 |
Last Refreshed: | 2024-11-14 15:02:11 |
Package Statistics | |
---|---|
Total Downloads: | 225,174 |
Monthly Downloads: | 4,894 |
Daily Downloads: | 193 |
Total Stars: | 28 |
Total Watchers: | 26 |
Total Forks: | 8 |
Total Open Issues: | 2 |
This is a Laravel wrapper / bridge for the Ably PHP library. It provides a Facade and an injectable AblyService that both act as a wrapper for a singleton Ably instance. The instance gets its parameters automatically from your config file or environment variables. You can also use AblyFactory for creating new Ably instances with (optional) custom parameters.
The PHP client library currently targets the Ably 1.1 client library specification. You can jump to the 'Known Limitations' section to see the features the PHP client library does not yet support or view our client library SDKs feature support matrix to see the list of all the available features.
Currently, this SDK only supports Ably REST. However, you can use the MQTT adapter to implement Ably's Realtime features using Python.
This SDK is not compatible with some of the Ably features:
| Feature | | --- | | Remember fallback host during failures | | MsgPack Binary Protocol |
Add this package to your project, with Composer
composer require ably/ably-php-laravel
Add the service provider in config/app.php
to the providers
array.
Ably\Laravel\AblyServiceProvider::class
Optionally add a reference to the facade in config/app.php
to the aliases
array.
'Ably' => Ably\Laravel\Facades\Ably::class
After adding the service provider, run the following command to have Laravel set up a configuration file for you.
php artisan vendor:publish
Update the created file config/ably.php
with your key or other options. You can also set the key using an environment variable named ABLY_KEY
.
The facade always returns a singleton instance created with options defined in the config file. Any methods available on an AblyRest class are available through the facade. Note that properties must be called like functions (i.e. Ably::auth()
), this is a limitation of PHP.
use Ably;
echo Ably::time(); // 1467884220000
$token = Ably::auth()->requestToken([ 'clientId' => 'client123', ]); // Ably\Models\TokenDetails
Ably::channel('testChannel')->publish('testEvent', 'testPayload', 'testClientId');
You can use Ably\Laravel\AblyService
instead of the facade, which acts as a 1:1 wrapper for an AblyRest singleton instance created with default options. Ably\Laravel\AblyFactory
lets you instantiate new AblyRest instances with (optional) custom options.
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'
}
Visit https://www.ably.io/documentation for a complete API reference and more examples.
This library uses semantic versioning. For each release, the following needs to be done:
origin
.git tag 1.0.0 && git push origin 1.0.0
.Copyright (c) 2017 Ably Real-time Ltd, Licensed under the Apache License, Version 2.0. Refer to LICENSE for the license terms.