dvsa / laminas-config-cloud-parameters
Installs: 11 779
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 1
Open Issues: 0
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
README
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.
How to use
In a Laminas MVC application
-
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%', ], ];
Available cloud parameter providers
AWS
Secrets Manager
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), ], // ... ], ], ];
Parameter Store
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), ], // ... ], ], ];