PHP code example of eserozvataf / scabbia2-config

1. Go to this page and download the library: Download eserozvataf/scabbia2-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eserozvataf / scabbia2-config example snippets


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);

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'];

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']);

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'];