watoki/cfg

Configuration loader

dev-master 2015-05-12 12:48 UTC

This package is not auto-updated.

Last update: 2024-12-21 15:13:54 UTC


README

cfg is a simple configuration loader.

Usage

Given you have a configuration class name\space\MyAppConfiguration then you can overwrite it with a deployment-specific configuration name\space\MyConfiguration in a file some/folder/MyConfiguration.php and load it with

$loader = new Loader(new Factory());
$config = $loader->loadConfiguration('name\space\MyAppConfiguration', 'some/folder/MyConfiguration.php');

This will result in MyConfiguration being set as singleton for MyAppConfiguration, so whenever the latter one is injected through the Factory, the former is used instead.

Note that MyConfiguration needs to be in the same namespace as MyAppConfiguration and the name of the containing file matches the class name.

Installation

To use cfg in your own project with Composer, add the following lines to your composer.json.

"require" : {
    "watoki/cfg" : "*"
}