luracast / config
lazy load configuration data from php files returning associative arrays
Installs: 129 653
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 3
Open Issues: 1
Requires
- php: >=5.5
Requires (Dev)
README
Config class for loading configuration arrays from various files and provide easy access to nested properties with dot syntax
Lazy loads configuration information when requested using Config::get('file.property','default_value')
or $config['file.property']
For example :-
Config::get('database.connections.sqlite', [])
will load database.php
which returns an array that contains connections property which contains the sqlite property
value of which will be returned. $path
given in the constructor is the path it will look for the file. If file does
not exist or the property does not exist, then the default value (set by the second parameter) will be returned.
If there is no default value, null will be returned.
When an environment string is specified, it will look for a folder with that name inside the path and use the returned array to override the properties is original config file thus allowing some customization
Setting A Configuration Value
Notice that "dot" style syntax may be used to access values in the various files. You may also set configuration values at run-time:
Config::set('database.default', 'sqlite');
Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests.