PHP code example of radiergummi / libconfig
1. Go to this page and download the library: Download radiergummi/libconfig 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/ */
radiergummi / libconfig example snippets
$config = new Config($data);
$config = new Config(PATH . 'example.json');
$config = new Config(PATH . 'example.php');
<?
return array(
'foo' => 'bar'
);
$config = new Config(PATH . 'app/config');
$config->set('foo', 'bar');
$config->set('font.roboto.italic.regular', 'roboto-regular-italic.woff');
$config->get('foo'); // bar
$fontlist = $config->get('font.roboto.italic'); // Array
$fontfile = $config->get('font.roboto.italic.regular'); // roboto-regular-italic.woff
$config->has('foo.sub.key'); // true
$config->erase('foo.sub.key');
$config->add(file_get_contents('another.json'));
print_r($config); // Array
try {
$config->add('inexistent/path/to/file.json');
} catch (Exception $e) {
$app->shutdown(502);
if (ENV === 'dev') throw new \MyApp\Exceptions\FileNotFoundException($e);
}
$settings = count($config);
array_walk_recursive($config, function ($value, $key) {
echo "$key holds $value\n";
});