SimpleConfig
SimpleConfig is a basic configuration container, for PHP., (*1)
Installation
To pull down dependencies and check version compatibility you will need to run composer in
the project root., (*2)
Usage
Values and factories can be provided in the constructor:, (*3)
$container = new \SimpleConfig\Container(
[
'field1' => 'value',
// etc
],
[
'field2' => function() {
return new Foo();
}
]
);
Alternatively, offsetSet and factory can be used to add values and factories respectively., (*4)
The Container class implements ArrayAccess, so values can simply be accessed using array syntax, e.g., (*5)
echo $container['field1']; // prints "value"
Factories are invoked once on field fetch, with the resulting value being cached for future use. Factories
can retrieve other values from the container by simply utilising $this, e.g., (*6)
$container->factory('foo', function() {
$class = $this['foo.class'];
return new $class();
});