In PHP handling configs even as array is not easy, when you need to reference related configs or replace strings in configs it is not straightforward. This library will help you define configurations in clean, decoupled and smart way resulting in easy retrieval of configuration values. How? read on.
This library is a PHP port of Namshi/Reconfig javascript library.
This library needs PHP 5.4+.
It has been tested using PHP5.4 to PHP5.6 and HHVM.
You can install the library directly with composer:
"namshi/preconfig": "0.1.0"
A simple example is given below:
namespace Your\Namespace
use Namshi\PreConfig\PreConfig;
public function foo()
{
$argument = [
'key1' => [
'key2' => '{{ key1.key3 }}',
'key3' => [
'key4' => 'value4',
'key5' => 'value5'
]
]
];
$preConfig = new PreConfig($argument);
$key3 = $preConfig->get('key1.key3');
}
You can see more examples in the example file.
We used phpspec to write tests. They are more like specs than just tests. You will need composer to get the dependencies, to run tests locally, execute the following commands:
ᐅ composer install --dev --prefer-source
ᐅ php vendor/bin/phpspec run
Add an issue, open a PR, drop us an email! We would love to hear from you!