LightPHPFramework

Config Class

The config class provides some functions to work with config files.

You can store your own config files in the config folder and you can load your customized configuration in your app.


List of public methods

Here is a list of available public methods for this class:


load($file, $extension = 'json')

This method load the given config file and return it as object.

Static Yes
Parameters Parameter Type Default Description
$file String Name of config file. Example: 'config'.
$extension String json Extension of given config file. Example: 'json'.
Example
		
Config::load('config');
		
	

get($file, $item = null, $default = null, $extension = 'json')

This method get value from given file / item file.

If no $item is given, the whole config file will be returned as object.

Static Yes
Parameters Parameter Type Default Description
$file String Name of config file. Example: 'config'.
$item String null The name of the item to retrieve. Multi-dimensional arrays can be accessed by separating the levels by a dot ".".
$default String null If given item is not found, the default value will be returned.
$extension String json Extension of given config file. Example: 'json'.
Example
		
var_dump(Config::get('config', 'project.name'));
// Output: string(17) "LightPHPFramework"