1. Go to this page and download the library: Download sugiphp/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/ */
$locator = new \SugiPHP\Config\FileLocator(__DIR__."/config");
$loader = new \SugiPHP\Config\JsonLoader($locator);
$config = new \SugiPHP\Config\Config($loader);
$config->get("app.production.host"); // returns example.com
$config->get("app.development"); // array("host" => "localhost", "debug" => 1)
$config->get("app.production.debug"); // will return NULL
$config->get("app.testing.host", "127.0.0.1"); // will return default value "127.0.0.1"
// search in one directory only
$locator = new FileLocator("/path/to/your/app/config/");
// search in several directories
$locator = new FileLocator(array("/path/to/your/app/config", "/other/config/path/"));
// add additional path
$locator->addPath("/somewhere/else/config/");
// Note that later method adds a path to the end. Locator will search in it only if the
// file was NOT found in the previously added paths. If you wish to add a path in the
// beginning of the search paths use:
$locator->unshiftPath("/first/search/path/");
// remove a search path from the end of the search paths:
$locator->popPath();
// remove a path from the beginning of the search paths:
$locator->shiftPath();