Giter VIP home page Giter VIP logo

etcd-php's Introduction

etcd-php

PHP client for Etcd v3

Build Status Latest Stable Version Total Downloads License

documentation

Requirements

  • PHP5.5+
  • Composer

Installation

composer require start-point/etcd-php

Usage

<?php
require 'vendor/autoload.php';
$client = new \Etcd\Client('127.0.0.1:2379');

/*********** kv ***********/
// set value
$client->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');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.