rstgroup / zf-external-config-consul-provider
Consul provider for rstgroup/zf-external-config-module
1.0
2017-07-26 12:48 UTC
Requires
- php: >= 5.6
- rstgroup/php-consul-kv-array-getter: ^1
- rstgroup/zf-external-config-module: ^1
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-11-10 03:46:29 UTC
README
This library contains provider that can fetch configuration from Consul Key/Value Storage.
Installation
Require module with Composer:
composer require rstgroup/zf-external-config-consul-provider
Then don't forget to enable provider and define factory in the zf-config-module
's
section of application's configuration:
return [ 'rst_group' => [ 'external_config' => [ 'providers' => [ \RstGroup\ZfExternalConfigConsulProvider\ConsulConfigProvider::class, ], 'service_manager' => [ 'factories' => [ \RstGroup\ZfExternalConfigConsulProvider\ConsulConfigProvider::class => \RstGroup\ZfExternalConfigConsulProvider\ConsulConfigProviderFactory::class ] ] ], ] ];
Configuration
Example configuration of provider might look just like this:
return [ 'rst_group' => [ 'external_config' => [ 'consul' => [ 'prefix' => 'my-app/', 'http_client' => [ 'base_uri' => 'http://consul.local:8500', ] ], ], ], ];
The provider's configuration should be placed under rsr_group.external_config.consul
key.
There are two sections:
prefix
key, which determines the base path in Consul's KV Storage. How it exactly works you can read inrstgroup/php-consul-kv-array-getter
's documentation.
If you don't provideprefix
, provider will return all keys returned by Consul KV API.http_client
key, which contains options passed toGuzzleHttp\Client
instance. The key that should interest you isbase_uri
which determines the base location of Consul's API. By default it's value ishttp://127.0.0.1:8500
.
More information about possible options are described in Guzzle Docs and in Guzzle's repository.