PHP code example of kris-ro / php-config

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

    

kris-ro / php-config example snippets




use KrisRo\PhpConfig\Config;

# static call
# providing a path (optional) to a folder here will load all json files in the folder
Config::buildConfig('/absolute/path/to/your/folder/with/json/files');

// magic call for debug and salt entries in the config array
Config::debug();
Config::salt();

// setter call
// set method returns the new value
Config::set('database/username', 'k2'); # returns 'k2'

Config::get('database/username'); # returns 'k2'

// path here is also optional; if provided all json files in that folder will be loaded
new Config('/absolute/path/to/your/folder/with/json/files');

$this->assertEquals('k2', Config::set('database/username', 'k2'));
// verify new value
$this->assertEquals('k2', Config::get('database/username'));

(new Config())
      ->loadConfigFile(/absolut/path/to/first.json')
      ->loadConfigFile(/absolut/path/to/second.json')
      ->loadConfigFile(/absolut/path/to/nth.json');

(new Config())
      ->setConfigPath('/absolute/path/to/your/folder/with/json/files')
      ->loadConfigFile(first-file-to-load.json')
      ->loadConfigFile(second-file-to-load.json')
      ->loadConfigFile(nth-file-to-load.json');