Yii2-etcd
Yii2 extension to access Etcd service., (*1)
Etcd is a key-value store for distributed systems., (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist weesee/yii2-etcd "*"
or add, (*5)
"weesee/yii2-etcd": "*"
to the require section of your composer.json
file., (*6)
Usage
Once the extension is installed, simply use it in your code by:, (*7)
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();
Credits
Thanks for your great job which this Yii2-extension is build on:, (*8)
Author / Licence
WeeSee weesee@web.de, (*9)
GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007, (*10)