https://github.com/ouqiang/etcd-php
PHP client for Etcd v3
https://github.com/ouqiang/etcd-php
etcd-client etcd-php etcdv3
Last synced: 12 months ago
JSON representation
PHP client for Etcd v3
- Host: GitHub
- URL: https://github.com/ouqiang/etcd-php
- Owner: ouqiang
- License: mit
- Created: 2017-06-17T01:40:24.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-03T13:31:40.000Z (over 3 years ago)
- Last Synced: 2025-06-01T06:31:55.965Z (about 1 year ago)
- Topics: etcd-client, etcd-php, etcdv3
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 71
- Watchers: 10
- Forks: 38
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etcd-php
PHP client for Etcd v3
[](https://travis-ci.org/ouqiang/etcd-php)
[](https://packagist.org/packages/start-point/etcd-php)
[](https://packagist.org/packages/ouqiang/etcd-php)
[](https://packagist.org/packages/start-point/etcd-php)
[documentation](https://github.com/ouqiang/etcd-php/wiki)
Requirements
------------
* PHP5.5+
* Composer
Installation
------------
```shell
composer require start-point/etcd-php
```
Usage
------------
```php
put('redis', '127.0.0.1:6379');
// set value and return previous value
$client->put('redis', '127.0.0.1:6579', ['prev_kv' => true]);
// set value with lease
$client->put('redis', '127.0.0.1:6579', ['lease' => 7587822882194199413]);
// get key value
$client->get('redis');
// get all keys
$client->getAllKeys();
// get keys with prefix
$client->getKeysWithPrefix('/v3/service/user/');
// delete key
$client->del('redis');
// compaction
$client->compaction(7);
/************ lease *****************/
$client->grant(3600);
// grant with ID
$client->grant(3600, 7587822882194199413);
// revoke a lease
$client->revoke(7587822882194199413);
// keep the lease alive
$client->keepAlive(7587822882194199413);
// retrieve lease information
$client->timeToLive(7587822882194199413);
/************ auth role user **************/
// enable authentication
$client->authEnable();
// disable authentication
$client->authDisable();
// get auth token
$client->authenticate('user', 'password');
// set auth token
$client->setToken($token);
// clear auth token
$client->clearToken();
// add a new role
$client->addRole('root');
// get detailed role information
$client->getRole('root');
// delete a specified role
$client->deleteRole('root');
// get lists of all roles
$client->roleList();
// add a new user
$client->addUser('user', 'password');
// get detailed user information
$client->getUser('root');
// delete a specified user
$client->deleteUser('root');
// get a list of all users.
$client->userList();
// change the password of a specified user
$client->changeUserPassword('user', 'new password');
// grant a role to a specified user
$client->grantUserRole('user', 'role');
// revoke a role of specified user
$client->revokeUserRole('user', 'role');
// grant a permission of a specified key or range to a specified role
$client->grantRolePermission('admin', \Etcd\Client::PERMISSION_READWRITE, 'redis');
// revoke a key or range permission of a specified role
$client->revokeRolePermission('admin', 'redis');
```