th3shadowbroker/json-configuration

A basic json-configuration.

v1.0.0 2019-04-23 21:22 UTC

This package is auto-updated.

Last update: 2021-01-09 22:50:03 UTC


README

This library (actually it's just a single file xD) contains a basic json-based configuration handler.

Composer

php-json-configuration is available on packagist:

composer require th3shadowbroker/json-configuration

Example

//Use class.
use github\th3shadowbroker\json_config\JsonConfiguration;

//Create a new config
$config = new JsonConfiguration(__DIR__.'/somefile.json');

//Set a default value.
$config->setDefault('something', 'anything');

//Set multiple defaults at once.
$config->setDefaults( ['another' => 'value'] );

//Set the value of a nested key.
$config->set('sonethingnested.nest', 'a nested value');

//Save the configuration.
$config->save();

//or save it to another location
$config->save(__DIR__.'/someotherfile.json');

echo $config->get('somethingnested.nest');