PHP code example of jascha030 / config-lib

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

    

jascha030 / config-lib example snippets




use Jascha030\ConfigurationLib\Config\ConfigStore;

//  Load composers autoloader. 

$configStore = new ConfigStore($dir);

// Make sure to call the load method before retrieving values.
$configStore->load();

// Retrieve value firstName from any of the config files in your directory.
if ($configStore->keyExists('firstName')) {
    $firstName = $configStore->get('firstName');
}

// Alternatively specify the exact file, using dot notation to retrieve firstName from /path/to/config/files/user.php
$configStore->get('user.firstName');

// Retrieve all values from /path/to/config/files/user.php
if ($configStore->configFileExists('user')) {
    $userConfig = $configStore->getConfig('user');
    $firstName  = $userConfig['firstName'];
}

// You can get the config file from an option's key.
$configFile = $configStore->getFileByOptionKey('firstName');

// You can validate if an option exists in a given file
$configStore->hasKey('user', 'firstName');