-
Notifications
You must be signed in to change notification settings - Fork 10
Options
Stefano Azzolini edited this page May 24, 2016
·
2 revisions
The Options module exposes functions to manage a data-value dictionary loading values from various formats.
See Dictionary.
You can load a config tree from a file or an array via the utility loaders methods :
Method | Description |
---|---|
loadArray |
Load directly an array of key->values |
loadPHP |
Load array key->values from a PHP file returning it. |
loadINI |
Load values from an .ini file. |
loadJSON |
Load JSON key->value map. |
loadENV |
Load environment variables from a .env file. |
Options::loadPHP('config.php');
config.php
<?php
return [
"debug" => false,
"cache" => [
"enabled" => true,
"driver" => "files",
"path" => "/tmp/cache",
],
];
Options::loadENV($dir,$envname='.env',$prefix_path=null)
/index.php
Options::loadENV(__DIR__);
print_r( Options::all() );
/.env
# This is a comment
BASE_DIR="/var/webroot/project-root"
CACHE_DIR="${BASE_DIR}/cache"
TMP_DIR="${BASE_DIR}/tmp"
Result:
Array
(
[BASE_DIR] => /var/webroot/project-root
[CACHE_DIR] => /var/webroot/project-root/cache
[TMP_DIR] => /var/webroot/project-root/tmp
)
Core is maintained by using the Semantic Versioning Specification (SemVer).
Copyright 2014-2016 Caffeina srl under the MIT license.
http://caffeina.com