PHP code example of rstgroup / php-consul-kv-array-getter
1. Go to this page and download the library: Download rstgroup/php-consul-kv-array-getter 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/ */
rstgroup / php-consul-kv-array-getter example snippets
use SensioLabs\Consul\ServiceFactory;
use SensioLabs\Consul\Services\KVInterface;
use RstGroup\PhpConsulKVArrayGetter\Consul\ConsulArrayGetter;
// your consul options:
$consulParams = [
'base_uri' => 'http://consul-domain:8500'
];
// prepare service that talks to Consul KV
$consulServicesFactory = new ServiceFactory($consulParams);
$kvService = $consulServicesFactory->get(KVInterface::class);
// create getter instance
$consulArrayGetter = new ConsulArrayGetter(
$kvService
);
// get the keys as structure
$result = $consulArrayGetter->getByPrefix('prefix');