Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 878 Bytes

README.md

File metadata and controls

45 lines (34 loc) · 878 Bytes

Config

Configuration loading and handling component based on Octris\PropertyCollection.

Usage

Example:

<?php

require_once 'vendor/autoload.php';

use \Octris\Config;

$cfg = new Config([
    'common' => [
        'database' => [
            'adapter' => 'mysql',
            'username' => 'example',
            'password' => '12345678',
        ]
    ]
]);
$cfg->merge((new Reader\Yaml())->loadString(<<<YAML
common:
    database:
        adapter: postgres
YAML
));
$cfg->merge((new Reader\Yaml())->loadFileIfExists('/etc/octris/config_test.yml'));

$db = $cfg->get('common.database');
print $db->get('adapter') . "\n";
print $db->get('username') . "\n";

$db->set('password', strrev($db->get('password')));
print $cfg->get('common.database.password') . "\n";

Output:

postgres
example
87654321