1. Go to this page and download the library: Download mattferris/configuration 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/ */
mattferris / configuration example snippets
use MattFerris\Configuration\Configuration;
use MattFerris\Configuration\Locators\FileLocator;
use MattFerris\Configuration\Loader\PhpLoader;
// setup a file locator with one or more search paths
$locator = new FileLocator(['foo/path', 'bar/path']);
// setup a loader for the type of files you want to load
$loader = new PhpLoader();
$config = new Configuration($locator, $loader);
// load a config file, the locator will search for the file using the search paths
$config->load('config.php');
// get a configuration value
$config->get('password');
// get a nested configuration value
$config->get('db.host');
// dump the configuration
$values = $config->get();
/*
* $values contains:
*
* [
* 'password' => 'banana',
* 'db' => [
* 'host' => 'localhost'
* ]
* ]
*/
// php config files must store all configuration in the $config variable
$config = [
'password' => 'banana',
'db' => [
'host' => 'localhost'
]
];