pflorek / aws-paramstore
该库从AWS参数存储读取参数。它支持路径前缀、可选的共享上下文和多个配置文件。返回字符串|int|float|bool的多维数组。可直接与zendframework/zend-config-aggregator集成。
v3.0.0
2019-08-08 14:15 UTC
Requires
- php: >=7.0
- aws/aws-sdk-php: ^3.71
- pflorek/elevator: ^2.0
Requires (Dev)
- phpunit/phpunit: >=5.7 <8.0
Suggests
- zendframework/zend-config-aggregator: Use directly as AWS Parameter Store Config Provider.
README
该库从AWS参数存储读取参数。它支持路径前缀、可选的共享上下文和多个配置文件。返回字符串|int|float|bool的多维数组。可直接与zendframework/zend-config-aggregator集成。
使用方法
use Aws\Ssm\SsmClient; use PFlorek\AwsParameterStore\ConfigProvider; // Provide bootstrap options $options = [ 'prefix' => '/path/with/prefix', // required 'name' => 'application-name', // required 'profileSeparator' => '_', // default => '_' 'sharedContext' => 'shared-context', // default => '' ]; // Configure AWS Systems Manager Client $client = new SsmClient([ 'version' => 'latest', 'region' => 'eu-central-1', ]); // Or just pass AWS Client options $client = [ 'version' => 'latest', 'region' => 'eu-central-1', ]; // Get provided config with active profiles $environments = ['test']; // Create AWS Parameter Store Config Provider $provider = new ConfigProvider($client, $options, $environments); $config = $provider(); // e.g. returns // //array(1) { // ["service"]=> // array(3) { // ["host"]=> // string(5) "mysql" // ["port"]=> // int(3306) // ["enabled"]=> // bool(true) // } //}
配置
示例
给定选项
- prefix := /path/with/prefix
- name := app-name
- profileSeparator := _
- sharedContext = shared
- profiles = ['common', 'test']
将搜索以下路径开始的参数
- /path/with/prefix/shared
- /path/with/prefix/app-name
- /path/with/prefix/app-name_common
- /path/with/prefix/app-name_test
安装
使用Composer安装包
composer require pflorek/aws-paramstore
作者
贡献
欢迎贡献!
许可协议
本包所有内容均受MIT许可协议许可。