dvsa / laminas-config-cloud-parameters
v2.0.0
2024-08-30 08:46 UTC
Requires
- php: ^8.2
- ext-json: *
- laminas/laminas-config: ^2|^3
- laminas/laminas-config-aggregator: ^1.7
- laminas/laminas-modulemanager: ^2.4|^3.0
- symfony/dependency-injection: ^5|^6|^7
- symfony/property-access: ^5|^6|^7
Requires (Dev)
- aws/aws-sdk-php: ^3.281
- bamarni/composer-bin-plugin: ^1.8
- dvsa/coding-standards: ^2.0
- laminas/laminas-mvc: ^3.3
- phpunit/phpunit: ^11.3
Suggests
- aws/aws-sdk-php: To use the AWS parameter providers
This package is auto-updated.
Last update: 2024-08-30 08:46:50 UTC
README
这个Composer库简化了Laminas配置占位符的使用,允许使用Symfony ParameterBag替换云服务提供的变量存储值。
如何使用
在Laminas MVC应用程序中
-
在配置中配置云提供商
<?php use Dvsa\LaminasConfigCloudParameters\Provider\SecretsManager; use Dvsa\LaminasConfigCloudParameters\Cast\Boolean; use Dvsa\LaminasConfigCloudParameters\Cast\Integer; return [ 'config_parameters' => [ 'providers' => [ SecretsManager::class => [ 'example-secret', // ... ], // ... ], 'casts' => [ // Uses `symfony/property-access` to access the property. See https://symfony.com.cn/doc/current/components/property_access.html#reading-from-arrays. '[foo]' => Boolean::class, '[bar][nested]' => Integer::class, // ... ], ], // ... ];
-
使用Laminas ModuleManager注册模块
<?php // module.config.php return [ 'Dvsa\LaminasConfigCloudParameters', // ... ];
-
然后可以将占位符添加到Laminas配置中
return [ 'foo' => '%bar%', 'bar' => [ 'nested' => '%baz%', ], ];
可用的云参数提供者
AWS
密钥管理器
仅支持存储在键/值对中的密钥。
示例配置
<?php return [ 'config_parameters' => [ 'providers' => [ SecretsManager::class => [ 'global-secrets', sprintf('environment-%s-secrets', $environment), ], // ... ], ], ];
参数存储
参数将按路径递归加载。键将是不包含路径的参数名称。
示例配置
<?php use Dvsa\LaminasConfigCloudParameters\Provider\ParameterStore; return [ 'config_parameters' => [ 'providers' => [ ParameterStore::class => [ '/global', sprintf('/env-%s', $environment), ], // ... ], ], ];