activecollab/etcd
最新稳定版本:1.0.4
Composer 安装命令:
composer require activecollab/etcd
包简介
etcd client with minimal dependencies
关键字:
README 文档
README
etcd is a distributed configuration system, part of the coreos project.
This repository provides a client library for etcd for PHP applications. It is based on linkorb/etcd-php. To learn why we forked it, jump here.
Installating etcd
To install etcd, follow instructions that etcd team posts on Releases page of the project:
https://github.com/coreos/etcd/releases/
Installing ActiveCollab/etcd
Easiest way is to install it using composer:
{
"require" : {
"activecollab/etcd": "^1.0"
}
}
Using Client
use use ActiveCollab\Etcd\Client as EtcdClient; $client = new EtcdClient('http://127.0.0.1:4001'); // Get, set, update, remove key if (!$client->exists('/key/name')) { $client->set('/key/name', 'value'); } $client->set('/key/name', 'value', 10); // Set TTL print $client->get('/key/name'); $client->update('/key/name', 'new value'); $client->remove('/key/name'); // Working with dirs if (!$client->dirExists('/dir/path')) { $client->createDir('/dir/path'); } $client->updateDir('/dir/path', 10); // Set TTL $client->removeDir('/dir/path'); // Get dir info $client->dirInfo('/dir/path'); // List subdirectories $client->listDirs('/dir/path'); // Return key value map for a given dir $client->getKeyValueMap('/dir/path')
Sandbox Path
If you configure sandbox path in the client instance, all keys will be prefixed with that path:
$client = new EtcdClient('http://127.0.0.1:4001'); $client->setSandboxPath('/my/namespace'); $client->set('/key/name', 'value'); // will set /my/namespace/key/name print $client->get('/key/name'); // will print /my/namespace/key/name
One more conenient method that client offers is option to call several commands in a specific sanbox, and have client revert back to the previous sandbox path when done:
$client = new EtcdClient('http://127.0.0.1:4001'); $client->setSandboxPath('/my/namespace'); // Path relative to the current sandbox path $client->sandboxed('./different/namespace', function(EtcdClient &$c) { $c->set('new_key', 123); // Sets /my/namespace/different/namespace/new_key }); // Absolute path $client->sandboxed('/different/namespace', function(EtcdClient &$c) { $c->set('new_key', 123); // Sets /different/namespace/new_key }); print $client->getSandboxPath(); // Prints '/my/namespace'
SSL
Client can be configured not to verify SSL peer:
$client = (new Client('https://127.0.0.1:4001'))->verifySslPeer(false);
as well as to use a custom CA file:
$client = (new Client('https://127.0.0.1:4001'))->verifySslPeer(true, '/path/to/ca/file');
Why Fork?
While original library works well, it depends on two big packages: Symfony Console and Guzzle. For a feature as low level as config access, we wanted something a bit nimbler, so we removed CLI commands and refactored the original library to use PHP's curl extension.
activecollab/etcd 适用场景与选型建议
activecollab/etcd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.16k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2015 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「client」 「etcd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 activecollab/etcd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 activecollab/etcd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 activecollab/etcd 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
Grpc PHP Client base on Swoole Http2 Coroutine
Grpc PHP Client base on Swoole Http2 Coroutine
Mock PSR-18 HTTP client
Utils to load, parse and work with configuration on Mezzio projects
Asynchronous MQTT client built on React
统计信息
- 总下载量: 15.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 33
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-16