1. Go to this page and download the library: Download minond/configurare 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/ */
minond / configurare example snippets
use Efficio\Configurare\Configuration;
$conf = new Configuration;
$conf->setDirectory('./config/');
// available parsers
use Efficio\Configurare\Parser\Json;
$conf->setExtension('.json'); // default is '.yml'
$conf->setParser(new Json); // default is Efficio\Configurare\Parser\Yaml
use Efficio\Configurare\Parser\Parser;
class CustomParser implements Parser
{
/**
* takes a raw string, parses it, and returns the array representing the
* data
* @param string $raw
* @return array
*/
public function decode($raw)
{
return unserialize($raw);
}
/**
* takes an array or an object and converts it into a string that can be
* saved in a file
* @param mixed $obj
* @return string
*/
public function encode($obj)
{
return serialize($obj);
}
}
$conf->setExtension('.custom');
$conf->setParser(new CustomParser);
// looks for in ./config/app.yml
// this gets [ 'name': ]
echo $conf->get('app:name'); // => My Application
// this gets [ 'usa': 'utah': 'provo': 'author': ]
echo $conf->get('app:usa:utah:provo:author'); // => Marcos Minond
// you can also get nested configuration files
// looks in config/users/2014/jan.yml
echo $conf->get('users/2014/jan:activities:music');
// if a key(s) already exists, just set it
$conf->set('app:name', 'My Other Application');
// if they do not then the write must be forced by passing a third parameter
// set to true
$conf->set('app:does:not:exists:yet', 'yes', true);
// I can have one enviroment or multiple
$conf->setEnvironments([ 'dev', 'test' ]);
// the following files will be parsed and merged before the configuration
// value is sent back
// - config/database.yaml
// - config/database.dev.yaml
// - config/database.test.yaml
$conf->get('database:connection:username');
use Efficio\Cache\NullCache;
$conf->setCache(new NullCache);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.