Functions to aid in reading and saving config items to and from configuration files.
The config files are expected to be found in the APPPATH .’/config’ folder. It does not currently work within modules.
Lonnie Ezell
| Config File Helper | Functions to aid in reading and saving config items to and from configuration files. |
| Functions | |
| read_config() | Returns an array of configuration settings from a single config file. |
| write_config() | Saves the passed array settings into a single config file located in the /config directory. |
| read_db_config() | Retrieves the config/database.php file settings. |
| write_db_config() | Saves the settings to the config/database.php file. |
function read_config( $file, $fail_gracefully = TRUE )
Returns an array of configuration settings from a single config file.
| $file | The config file to read. |
| $fail_gracefully | true/false. Whether to show errors or simply return false. |
An array of settings, or false on failure (when $fail_gracefully = true).
function read_db_config( $environment = null, $new_db = NULL, $fail_gracefully = TRUE )
Retrieves the config/database.php file settings. Plays nice with CodeIgniter 2.0’s multiple environment support.
| $environment | (Optional) The envinroment to get. If empty, will return all environments. |
| $new_db (str) | (Optional) Returns an new db config array with parameter as $db active_group name |
| $fail_gracefully | true/false. Whether to halt on errors or simply return false. |
An array of database settings or abrupt failure (when $fail_gracefully == FALSE)
Returns an array of configuration settings from a single config file.
function read_config( $file, $fail_gracefully = TRUE )
Saves the passed array settings into a single config file located in the /config directory.
function write_config( $file = '', $settings = null )
Retrieves the config/database.php file settings.
function read_db_config( $environment = null, $new_db = NULL, $fail_gracefully = TRUE )
Saves the settings to the config/database.php file.
function write_db_config( $settings = null )