PHP code example of linkorb / etcd-php

1. Go to this page and download the library: Download linkorb/etcd-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

linkorb / etcd-php example snippets


$client = new Client($server);

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

$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
$client->rm('/foo');

// Create a directory
$client->mkdir('/fooDir');
// Remove dir
$client->rmdir('/fooDir');    
shell
composer 
bash
$ bin/etcd-php etcd:set /foo/bar "Hello world"
bash
$ bin/etcd-php etcd:set /foo/bar "Hello world" --ttl=60
bash
$ bin/etcd-php etcd:get /foo/bar