sunnyphp/ttlock
Composer 安装命令:
composer require sunnyphp/ttlock
包简介
TTLock SDK
README 文档
README
PHP SDK for TTLock Cloud API v3
Installation
See clients & adapters list in HTTPlug documentation if you're using another HTTP client (not Guzzle 7).
HTTP client should be compatible with PSR-18 (implementing psr/http-client-implementation).
composer require sunnyphp/ttlock php-http/guzzle7-adapter
<?php declare(strict_types=1); require_once __DIR__ . '/vendor/autoload.php'; use SunnyPHP\TTLock\Configuration; use SunnyPHP\TTLock\Entrypoint; use SunnyPHP\TTLock\Request\Lock\GetList; use SunnyPHP\TTLock\Request\Lock\Initialize; use SunnyPHP\TTLock\Request\OAuth2\AccessToken; use SunnyPHP\TTLock\Request\User\Register; use SunnyPHP\TTLock\Transport; // initial configuration $entrypoint = new Entrypoint( new Configuration('client_id', 'client_secret', /* access token if needed */), new Transport(\Http\Adapter\Guzzle7\Client::createWithConfig([ 'verify' => false, // disable certificates check ])), ); // register user; retrieve TTLock Cloud API username $register = $entrypoint->getUserRegister(new Register('username', 'password')); var_dump($register->getResponseArray()); // get access token; retrieve access token, refresh token, expiration, etc $tokenResponse = $entrypoint->getOAuth2AccessToken(new AccessToken($register->getUsername(), 'password')); var_dump($tokenResponse->getResponseArray()); // save token response to future requests or refreshing token // ... // inject access token to entrypoint configuration (most of the requests required access token) $entrypoint = $entrypoint->withConfigurationAccessToken($tokenResponse->getAccessToken()); // initialize new lock; access token used under hood; retrieve lockId, keyId $lockData = 'TTLock SDK should return lockData here'; $newLockIds = $entrypoint->getLockInitialize(new Initialize($lockData)); var_dump($newLockIds->getResponseArray()); // get all initialized locks $locks = $entrypoint->getLockList(new GetList()); var_dump($locks->getResponseArray()); // other requests
Exception structure
\SunnyPHP\TTLock\Exception\ApiException- communication or system errors\SunnyPHP\TTLock\Exception\CommonException- if response has errors\SunnyPHP\TTLock\Exception\KeyException- if response hasEkey-associated errors\SunnyPHP\TTLock\Exception\GatewayException- if response hasGateway-associated errors\SunnyPHP\TTLock\Exception\LockException- if response hasLock-associated errors\SunnyPHP\TTLock\Exception\PasscodeException- if response hasPasscodeorIC-associated errors
\Webmozart\Assert\InvalidArgumentException- if passed data is invalid
sunnyphp/ttlock 适用场景与选型建议
sunnyphp/ttlock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.59k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sdk」 「ttlock」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sunnyphp/ttlock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sunnyphp/ttlock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sunnyphp/ttlock 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
debug
A PSR-7 compatible library for making CRUD API endpoints
debug
debug
A lightweight plain-PHP framework for database-backed CRUD APIs.
Modern, strongly-typed, PSR-compliant PHP client for the WeFact v2 API.
统计信息
- 总下载量: 1.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: WTFPL
- 更新时间: 2023-11-16