PHP code example of th3shadowbroker / json-configuration

1. Go to this page and download the library: Download th3shadowbroker/json-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/ */

    

th3shadowbroker / json-configuration example snippets


//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');