All Projects → ably → ably-php

ably / ably-php

Licence: Apache-2.0 license
PHP client library SDK for Ably realtime messaging service

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ably-php

Ably Js
Javascript, Node, Typescript client library SDK for Ably realtime messaging service
Stars: ✭ 99 (+141.46%)
Mutual labels:  client-library
Node Sparkpost
SparkPost client library for Node.js
Stars: ✭ 177 (+331.71%)
Mutual labels:  client-library
java-binance-api
Java Binance API Client
Stars: ✭ 72 (+75.61%)
Mutual labels:  client-library
Iyzipay Node
iyzipay api node.js client
Stars: ✭ 116 (+182.93%)
Mutual labels:  client-library
Go Nsq
The official Go package for NSQ
Stars: ✭ 2,045 (+4887.8%)
Mutual labels:  client-library
Google Maps Services Js
Node.js client library for Google Maps API Web Services
Stars: ✭ 2,432 (+5831.71%)
Mutual labels:  client-library
Mariadbpp
C++ client library for MariaDB.
Stars: ✭ 76 (+85.37%)
Mutual labels:  client-library
streamr-client-javascript
JS library for interacting with Streamr APIs: publishing and subscribing to data, creating streams, etc.
Stars: ✭ 35 (-14.63%)
Mutual labels:  client-library
Docker Java
Java Docker API Client
Stars: ✭ 2,166 (+5182.93%)
Mutual labels:  client-library
Jreactive 8583
Java Client & Server for ISO8583 & Netty
Stars: ✭ 248 (+504.88%)
Mutual labels:  client-library
Xmlrpc
Implementation of XMLRPC protocol in Go language.
Stars: ✭ 133 (+224.39%)
Mutual labels:  client-library
Rosnodejs
Client library for writing ROS nodes in JavaScript with nodejs
Stars: ✭ 145 (+253.66%)
Mutual labels:  client-library
Iyzipay Php
iyzipay api php client
Stars: ✭ 205 (+400%)
Mutual labels:  client-library
Google Maps Services Java
Java client library for Google Maps API Web Services
Stars: ✭ 1,497 (+3551.22%)
Mutual labels:  client-library
iyzipay-dotnet-client
iyzipay api .net framework and .net core client
Stars: ✭ 30 (-26.83%)
Mutual labels:  client-library
Google Api Nodejs Client
Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
Stars: ✭ 9,722 (+23612.2%)
Mutual labels:  client-library
Php Sparkpost
SparkPost client library for PHP
Stars: ✭ 190 (+363.41%)
Mutual labels:  client-library
ably-cocoa
iOS, tvOS and macOS Objective-C and Swift client library SDK for Ably realtime messaging service
Stars: ✭ 33 (-19.51%)
Mutual labels:  client-library
kubernetes-client-lambda
one-line kubernetes client: light-weight, lambda-styled, easy-testing. For a simplified kubernetes programming.
Stars: ✭ 47 (+14.63%)
Mutual labels:  client-library
Alpaca
Given a web API, Generate client libraries in node, php, python, ruby
Stars: ✭ 2,447 (+5868.29%)
Mutual labels:  client-library

Ably

Latest Stable Version Total Downloads License

Ably is the platform that powers synchronized digital experiences in realtime. Whether attending an event in a virtual venue, receiving realtime financial information, or monitoring live car performance data – consumers simply expect realtime digital experiences as standard. Ably provides a suite of APIs to build, extend, and deliver powerful digital experiences in realtime for more than 250 million devices across 80 countries each month. Organizations like Bloomberg, HubSpot, Verizon, and Hopin depend on Ably’s platform to offload the growing complexity of business-critical realtime data synchronization at global scale. For more information, see the Ably documentation.

This is a PHP REST client library for Ably. The library currently targets the Ably 1.1 client library specification. You can jump to the 'Known Limitations' section to see the features this client library does not yet support or view our client library SDKs feature support matrix to see the list of all the available features.

Supported Platforms

This SDK supports PHP 7.2+, 8.0, 8.1 and 8.2

We regression-test the library against a selection of PHP versions (which will change over time, but usually consists of the versions that are supported upstream). Please refer to the check workflow for the set of versions that currently undergo CI testing.

We'll happily support (and investigate reported problems with) any reasonably-widely-used PHP version. If you find any compatibility issues, please do raise an issue in this repository or contact Ably customer support for advice.

Known Limitations

Currently, this SDK only supports Ably REST. However, you can use the MQTT adapter to implement Ably's Realtime features using Mosquitto PHP.

Documentation

Visit https://www.ably.com/docs for a complete API reference and more examples.

Installation

Via composer

The client library is available as a composer package on packagist. If you don't have composer already installed, you can get it from https://getcomposer.org/.

Install Ably from the shell with:

$ composer require ably/ably-php --update-no-dev

Then simply require composer's autoloader:

require_once __DIR__ . '/vendor/autoload.php';

Manual installation

Clone or download Ably from this repo and require ably-loader.php:

require_once __DIR__ . '/ably-php/ably-loader.php';

Using the REST API

Introduction

All examples assume a client and/or channel has been created as follows:

$client = new Ably\AblyRest('your.appkey:xxxxxx');
$channel = $client->channel('test');

Publishing a message to a channel

$channel->publish('myEvent', 'Hello!'); // => true

Querying the History

$messagesPage = $channel->history(); // => \Ably\Models\PaginatedResult
$messagesPage->items[0]; // => \Ably\Models\Message
$messagesPage->items[0]->data; // payload for the message
$messagesPage->next(); // retrieves the next page => \Ably\Models\PaginatedResult
$messagesPage->hasNext(); // false, there are no more pages

Presence on a channel

$membersPage = $channel->presence->get(); // => \Ably\Models\PaginatedResult
$membersPage->items[0]; // first member present in this page => \Ably\Models\PresenceMessage
$membersPage->items[0]->clientId; // client ID of first member present
$membersPage->next(); // retrieves the next page => \Ably\Models\PaginatedResult
$membersPage->hasNext(); // false, there are no more pages

Querying the Presence History

$presencePage = $channel->presence->history(); // => \Ably\Models\PaginatedResult
$presencePage->items[0]; // => \Ably\Models\PresenceMessage
$presencePage->items[0]->clientId; // client ID of first member
$presencePage->next(); // retrieves the next page => \Ably\Models\PaginatedResult

Getting the channel status

$channelStatus = $channel->status(); // => \Ably\Models\Status\ChannelDetails
var_dump($channelStatus); 

Generate Token and Token Request

$tokenDetails = $client->auth->requestToken();
// => \Ably\Models\PresenceMessage
$tokenDetails->token; // => "xVLyHw.CLchevH3hF....MDh9ZC_Q"

$client = new Ably\AblyRest( $tokenDetails->token );
// or
$client = new Ably\AblyRest( array( 'tokenDetails' => $tokenDetails ) );

$token = $client->auth->createTokenRequest();
// => {"id" => ...,
//     "clientId" => null,
//     "ttl" => 3600,
//     "timestamp" => ...,
//     "capability" => "{\"*\":[\"*\"]}",
//     "nonce" => ...,
//     "mac" => ...}

Fetching your application's stats

$statsPage = client->stats(); // => \Ably\Models\PaginatedResult
$statsPage->items[0]; // => \Ably\Models\Stats
$statsPage->next(); // retrieves the next page => \Ably\Models\PaginatedResult

Fetching the Ably service time

$client->time(); // in milliseconds => 1430313364993

Laravel realtime broadcasting

If you're using Laravel and want to support realtime broadcasting and events, you may want to check out laravel-broadcaster.

If you want ably-php as a rest dependency across service providers, check ably-php-laravel. ably-php-laravel is a simple wrapper over ably-php with laravel-specific classes. This has limited use-cases and laravel-broadcaster is recommended over ably-php-laravel for most use-cases.

Support, feedback and troubleshooting

Please visit http://support.ably.com/ for access to our knowledgebase and to ask for any assistance.

You can also view the community reported Github issues.

To see what has changed in recent versions of Bundler, see the CHANGELOG.

Known limitations

  1. This client library requires PHP version 5.4 or greater

Running the tests

The client library uses the Ably sandbox environment to provision an app and run the tests against that app. In order to run the tests, you need to:

git clone https://github.com/ably/ably-php.git
cd ably-php
composer install
git submodule init
git submodule update
./vendor/bin/phpunit

Note - If there is a issue while running tests [SSL certificate error: unable to get local issuer certificate], please set SSL cert path in php.ini. For more information, follow https://aboutssl.org/fix-ssl-certificate-problem-unable-to-get-local-issuer-certificate/

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Ensure you have added suitable tests and the test suite is passing (run vendor/bin/phpunit)
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Release Process

This library uses semantic versioning. For each release, the following needs to be done:

  1. Update the version number in src/Defaults.php
  2. Create a new branch for the release, named like release/1.0.0 (where 1.0.0 is what you're releasing, being the new version).
  3. Run github_changelog_generator to automate the update of the CHANGELOG. Once the CHANGELOG update has completed, manually change the Unreleased heading and link with the current version number such as 1.0.0. Also ensure that the Full Changelog link points to the new version tag instead of the HEAD.
  4. Commit generated CHANGELOG.md file.
  5. Make a PR against main.
  6. Once the PR is approved, merge it into main.
  7. Add a tag and push to origin such as git tag 1.0.0 && git push origin 1.0.0.
  8. Visit https://github.com/ably/ably-php/tags and add release notes for the release including links to the changelog entry.
  9. Visit https://packagist.org/packages/ably/ably-php, log in to Packagist, and click the "Update" button.
  10. Remember to make a release update for laravel-broadcaster and ably-php-laravel.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].