Etcd client library for PHP

v1.6.1 2020-05-15 08:08 UTC

This package is auto-updated.

Last update: 2022-11-25 09:32:26 UTC


Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Etcd client library for PHP

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

This repository provides a client library for etcd for PHP applications.

Installing and running etcd

git clone
cd etcd

Brought to you by the LinkORB Engineering team

Check out our other projects at

Btw, we're hiring!


composer require linkorb/etcd-php


The client

Instantiate the client

$client = new Client($server);

Instantiate the client with custom Guzzle Client

$client = Client::constructWithGuzzleClient($guzzleClient, $server);

Use the client instance

$client->set('/foo', 'fooValue');
// Set the ttl
$client->set('/foo', 'fooValue', 10);
// get key value
echo $client->get('/foo');

// Update value with key
$client->update('/foo', 'newFooValue');

// Delete key

// Create a directory
// Remove dir

The command line tool

Setting Key Values

Set a value on the /foo/bar key:

$ bin/etcd-php etcd:set /foo/bar "Hello world"

Set a value on the /foo/bar key with a value that expires in 60 seconds:

$ bin/etcd-php etcd:set /foo/bar "Hello world" --ttl=60

Create a new key /foo/bar, only if the key did not previously exist:

$ bin/etcd-php etcd:mk /foo/new_bar "Hello world"

Create a new dir /fooDir, only if the key did not previously exist:

$ bin/etcd-php etcd:mkdir /fooDir

Update an existing key /foo/bar, only if the key already existed:

$ bin/etcd-php etcd:update /foo/bar "Hola mundo"

Create or update a directory called /mydir:

$ bin/etcd-php etcd:setDir /mydir

Retrieving a key value

Get the current value for a single key in the local etcd node:

$ bin/etcd-php etcd:get /foo/bar

Listing a directory

Explore the keyspace using the ls command

$ bin/etcd-php etcd:ls
$ bin/etcd-php etcd:ls /adir

Add -recursive to recursively list subdirectories encountered.

$ bin/etcd-php etcd:ls --recursive

Deleting a key

Delete a key:

$ bin/etcd-php etcd:rm /foo/bar

Delete an empty directory or a key-value pair

$ bin/etcd-php etcd:rmdir /path/to/dir 

Recursively delete a key and all child keys:

$ bin/etcd-php etcd:rmdir /path/to/dir --recursive

Export node

$ bin/etcd-php etcd:export --server= --format=json --output=config.json /path/to/dir

Watching for changes

Watch for only the next change on a key:

$ bin/etcd-php etcd:watch /foo/bar