scabbiafw/scabbia2-config

This package is abandoned and no longer maintained. The author suggests using the eserozvataf/scabbia2-config package instead.

Scabbia2 Config Component

v0.1.1 2015-09-16 07:45 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:51:20 UTC


README

This component is a configuration compiler which supports binding multiple configuration files.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version Documentation Status

Usage

Merging multiple configurations

use Scabbia\Config\ConfigCollection;

$confs = new ConfigCollection();

// add a yaml-parsed configuration
$yaml = new \Scabbia\Yaml\Parser();
$confs->add($yaml->parse(file_get_contents('common.yml')));

// ...and/or add a json file
$confs->add(json_decode(file_get_contents('production.json')));

// ...and/or add a configuration value manually
$confs->add([
    'env' => 'development'
]);

// output the result
$config = $confs->save();
print_r($config);

Overriding an existing configuration item

use Scabbia\Config\ConfigCollection;

$confs = new ConfigCollection();

$confs->add([
    'env' => 'production'
]);

// in second config you can override a value with 'important' flag
$confs->add([
    'env|important' => 'development'
]);

// output the result
$config = $confs->save();
echo $config['env'];

Constructing a list in separate configurations

use Scabbia\Config\ConfigCollection;

$confs = new ConfigCollection();

$confs->add([
    'items|list' => [
        'first',
        'second'
    ]
]);

// in second config you can override a value with 'important' flag
$confs->add([
    'items|list' => [
        'third'
    ]
]);

// output the result
$config = $confs->save();
print_r($config['items']);

Flatten configuration value keys

use Scabbia\Config\ConfigCollection;

$confs = new ConfigCollection();

$confs->add([
    'database|flat' => [
        'mongo' => [
            'username' => 'scabbia2',
            'password' => 'testing'
        ]
    ]
]);

// output the result
$config = $confs->save();
echo $config['database/mongo/username'];
echo $config['database/mongo/password'];

Links

Contributing

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome. All contributions should be filed on the eserozvataf/scabbia2-config repository.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub issues.
  • To support: Donate