This Composer library facilitates the use of Laminas config placeholders, enabling the substitution of values with those supplied by cloud services dedicated to variable storage using Symfony ParameterBag.
-
Configure the Cloud providers in your configuration:
<?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/doc/current/components/property_access.html#reading-from-arrays. '[foo]' => Boolean::class, '[bar][nested]' => Integer::class, // ... ], ], // ... ];
-
Register the module with the Laminas ModuleManager:
<?php // module.config.php return [ 'Dvsa\LaminasConfigCloudParameters', // ... ];
-
Placeholders can be then added to the Laminas config:
return [ 'foo' => '%bar%', 'bar' => [ 'nested' => '%baz%', ], ];
Only secrets that are stored in key/value pairs are supported.
Example configuration:
<?php
return [
'config_parameters' => [
'providers' => [
SecretsManager::class => [
'global-secrets',
sprintf('environment-%s-secrets', $environment),
],
// ...
],
],
];Parameters will be loaded recursively by path. The key will be parameter name without the path provided as the key.
Example configuration:
<?php
use Dvsa\LaminasConfigCloudParameters\Provider\ParameterStore;
return [
'config_parameters' => [
'providers' => [
ParameterStore::class => [
'/global',
sprintf('/env-%s', $environment),
],
// ...
],
],
];