Download the PHP package susina/param-resolver without Composer
On this page you can find all versions of the php package susina/param-resolver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download susina/param-resolver
More information about susina/param-resolver
Files in susina/param-resolver
Package param-resolver
Short Description Resolve parameters inside a configuration array
License Apache-2.0
Informations about the package param-resolver
Parameter Resolver
ParamResolver is a small class to resolve parameters in configuration arrays. It's heavily inspired on Symfony ParameterBag class.
Installation
Install the library via composer:
composer require susina/param-resolver
Usage
In a configuration array, it can be useful to define some parameters.
A parameter is a previously defined property, put between % special character. When ParamResolver found a parameter, it simply replaces its placeholder with the previously defined value. In the following example, suppose you have a json configuration file:
First of all you have to convert it into an array, then you can resolve the parameters:
Now the json content is the following:
You can escape the special character % by doubling it:
jeans property now contains the string '20%'.
[!Note] Both keys and values of your array can contain parameters.
Special parameters: environment variables
The string env
is used to specify an environment variable.
Many hosts give services or credentials via environment variables and you can use them in your configuration file via env.variable
syntax. In example, let’s suppose to have the following environment variables:
In your (yaml) configuration file you can write:
and, after processing, it becomes:
Issues
If you find a bug or any other issue, please report it on Github.
Contributing
Please, see CONTRIBUTING.md
Licensing
This library is released under Apache-2.0 license.