PHP code example of weesee / yii2-etcd

1. Go to this page and download the library: Download weesee/yii2-etcd 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/ */

    

weesee / yii2-etcd example snippets

 

    use weesee\etcd\Etcd;
    
    // setup connection to Etcd
    // setting root means all key are appended to this path
    $etcd = new Etcd([
        'etcdUrl' => 'http://127.0.0.1:2379',
        'root'=>"/yii2-etcd-test/"
    ]);
    
    // write key value pairs to etcd
    if ($etcd->exists("name"))
        $etcd->update("name","value");  // updates "/yii2-etcd-test/name"
    else
        $etcd->set("name","value");     // sets "/yii2-etcd-test/name"

    // remove key
    $etcd->removeKey("name");           // removes "/yii2-etcd-test/name"
    
    // get keys with values in current directory "/yii2-etcd-test"
    // as ArrayDataProvider. Simple to use for GidViews,...
    $dataProvider = $etcd->getKeyValueAsDataProvider(); 


php composer.phar