Download the PHP package alex-unruh/dot-notation-config without Composer
On this page you can find all versions of the php package alex-unruh/dot-notation-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alex-unruh/dot-notation-config
More information about alex-unruh/dot-notation-config
Files in alex-unruh/dot-notation-config
Package dot-notation-config
Short Description An abstraction layer to get data from array or a file built on Dflydev\DotAccessData\Data
License MIT
Homepage https://github.com/alex-unruh/dot-notation-config
Informations about the package dot-notation-config
Alex Unruh - Config
This library is based on the Laravel config concept. It values performance and was built on top of the library Dflydev Dot Access data.
The difference is that we can also access the data from a file instead of just an array in runtime execution.
How to install:
Usage with files:
You can have as many configuration files as you want
Usage with virtual data:
Methods:
The methods is the same presents in Dflydev Dot Access data. The difference is that the first argument in dot-notations is a file or a virtual config set alias defined on setDir or setData methods described above.
Methods: setDir, setData, get, set, has, remove and append.
Tricks:
As the library only has static methods, you can set the configuration files directory at any time or in any file called before manipulating the data through the class's methods.
Define the config dir in a file like a entry point and don't worry about him anymore...
// public/index.php
$config_path = $_SERVER['DOCUMENT_ROOT'] . $_ENV['BASE_PATH'] . '/config';
Config::setDir($config_path);
// controllers/services/MyService.php
echo Config::get('app.app_name'); // 'My App'