1. Go to this page and download the library: Download ckr/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/ */
ckr / config example snippets
$myConfig = [
'root' => [
'specific' => ['key' => 'val'],
],
];
// plain php is a bit ugly...
$theSpecific = isset($myConfig['root']['specific']['key']) ?
$myConfig['root']['specific']['key'] : null;
$theGeneral = isset($myConfig['root']['key']) ?
$myConfig['root']['key'] : false;
// ... but with a `Config` it looks nicer:
$config = new Ckr\Config\Config($myConfig);
$theSpecific = $config->get('root/specific/key');
$theGeneral = $config->get('root/key', false);
$loggingConfig = $c->child('logging'); /* @var $loggingConfig Config */
// we can now provide only the relevant data to thr logging factory
$myLoggingFactory = new $loggingFactoryClass;
$logger = $myLoggingFactory->create($loggingConfig);
// the logging factory "sees" only the data of the "logging" child array
public function create(Config $cfg)
{
$loggers = $cfg->get('loggers'); // $loggers is an array
foreach ($loggers as $logger) { /* ... */ }
// ...
}