PHP code example of jackchang1025-clagiordano / weblibs-configmanager
1. Go to this page and download the library: Download jackchang1025-clagiordano/weblibs-configmanager 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/ */
jackchang1025-clagiordano / weblibs-configmanager example snippets
return array (
'app' => 'app_name',
'db' =>
array (
'host' => 'localhost',
'user' => 'sample_user',
'pass' => 'sample_pass',
'port' => 3306,
),
'other' =>
array (
'multi' =>
array (
'deep' =>
array (
'nested' => 'config_value',
),
),
),
);
use clagiordano\weblibs\configmanager\ConfigManager;
/**
* Instance object to read argument file
*/
$config = new ConfigManager("configfile.php");
/**
* Check if a value exists into config file
*/
$value = $config->existValue('app');
/**
* Read a simple element from config file
*/
$value = $config->getValue('app');
/**
* Access to a nested element from config
*/
$nestedValue = $config->getValue('other.multi.deep.nested');
/**
* Change config value at runtime
*/
$this->config->setValue('other.multi.deep.nested', "SUPERNESTED");
/**
* Save config file with original name (OVERWRITE)
*/
$this->config->saveConfigFile();
/**
* Save config file with original name (OVERWRITE)
*/
$this->config->saveConfigFile('/new/file/name/or/path/test.php');
/**
* Optionally you can also reload config file from disk after save
*/
$this->config->saveConfigFile('/new/file/name/or/path/test.php', true);
/**
* Load another configuration file without reinstance ConfigManager
*/
$this->config->loadConfig('another_config_file.php');