定制 ably/ably-php-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ably/ably-php-laravel

Composer 安装命令:

composer require ably/ably-php-laravel

包简介

Ably realtime REST PHP library wrapper for Laravel

README 文档

README

Ably Pub/Sub PHP Laravel Header Latest Stable Version License

Ably Pub/Sub PHP Laravel SDK

Build using Ably’s Pub/Sub PHP Laravel SDK, supported on all popular platforms and frameworks.

This Laravel package provides a clean integration with the Ably PHP SDK. It includes a Facade and an injectable AblyService that wrap a singleton Ably instance, with configuration automatically loaded from your environment variables or config files. Additionally, the AblyFactory class lets you create new Ably instances with custom parameters when needed.

This SDK provides REST-only functionality for Laravel. For full-featured Laravel integration including real-time capabilities, Ably recommend using Ably's Laravel Broadcaster.

Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messaging, message history, presence, and push notifications. Utilizing Ably’s realtime messaging platform, applications benefit from its highly performant, reliable, and scalable infrastructure.

Find out more:

Getting started

Everything you need to get started with Ably:

Supported platforms

Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact Ably support.

The PHP client library currently targets the Ably 1.1 client library specification.

Note

See laravel-broadcaster, if you're using Laravel and want to support Realtime broadcasting and events.

Important

PHP SDK versions < 1.1.9 will be deprecated from November 1, 2025.

Installation

Install the package using 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

Configuration

After registering the service provider, publish the configuration file using Artisan:

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.

Usage

The following sections demonstrates two ways to use Ably in Laravel: via a Facade or through dependency injection.

Facade

Use the Laravel facade to access the Ably client.

Facade usage details.

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. Due to PHP limitations, properties must be accessed as methods, for example Ably::auth()):

use Ably;

echo Ably::time(); // 1467884220000
$token = Ably::auth()->requestToken([ 'clientId' => 'client123', ]); // Ably\Models\TokenDetails
Ably::channel('testChannel')->publish('testEvent', 'testPayload', 'testClientId');

Dependency injection

Use the dependency injection to access the Ably client.

Dependency injection usage details.

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'
}

Releases

The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.

Contributing

Read the CONTRIBUTING.md guidelines to contribute to Ably.

Support, feedback, and troubleshooting

For help or technical support, visit the Ably Support page.

Ably REST API

This SDK currently supports only the Ably REST API. If you need to subscribe to realtime events in PHP, consider using the MQTT adapter to leverage Ably's Realtime features.

ably/ably-php-laravel 适用场景与选型建议

ably/ably-php-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 332.43k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2016 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rest」 「messaging」 「laravel」 「ably」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ably/ably-php-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ably/ably-php-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 ably/ably-php-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 332.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 24
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 22
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-07-11