Code Monkey home page Code Monkey logo

etcd-php's Introduction

Etcd PHP Client

etcd is a distributed configuration system, part of the coreos project.

This repository provides a client library for etcd for PHP applications. Inspired by linkorb/etcd-php. For our purpose, we need a more elastic version for etcd client. It can use with predefined HTTP client (no matter what it is) and also supports PHP 7.1.

The etcd-php uses curl library as a default client and creates own instance of http client.

Installating etcd

To install etcd, follow instructions that etcd team posts on Releases page of the project:

https://github.com/DatingVIP/etcd/releases/

Installing DatingVIP/etcd

Easiest way is to install it using composer:

{
    "require" : {
        "DatingVIP/etcd": "^1.0"
    }
}

Using Client

use use DatingVIP\Component\Etcd\Client;

$client = new Client('http://127.0.0.1:4001');

// If you have own http client object & if it has proper adapter 
// proper means - need to implement DatingVIP\Component\Etcd\Client\HttpInterface)
$httpAdapter = new MyAdapter($myHttpClient);
$client->setHttpClient($httpAdapter);

// Get, set, update, remove key
if (!$client->keyExists('/key/name')) {
    $client->keySet('/key/name', 'value');
}
$client->set('/key/name', 'value', 10); // Set TTL
print $client->keyGet('/key/name');

$client->keyUpdate('/key/name', 'new value');

$client->keyRemove('/key/name');

// Working with dirs
if (!$client->dirExists('/dir/path')) {
    $client->dirCreate('/dir/path');
}
$client->dirUpdate('/dir/path', 10); // Set TTL
$client->dirRemove('/dir/path');

// Get dir info
$client->dirInfo('/dir/path');

// List subdirectories
$client->dirList('/dir/path');

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');

etcd-php's People

Contributors

kornrunner avatar pmiroslawski avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.