DikkiConfig Code
Write and Parse Config Files in YAML, JSON, INI or PHP Array format
Brought to you by:
namankumar80510
File | Date | Author | Commit |
---|---|---|---|
src | 2023-09-14 | Naman Kumar | [8ea2a0] config package complete |
.gitignore | 2023-09-14 | Naman Kumar | [8ea2a0] config package complete |
LICENSE | 2023-09-14 | Naman Kumar | [8ea2a0] config package complete |
README.md | 2023-09-14 | Naman Kumar | [8ea2a0] config package complete |
composer.json | 2023-09-14 | Naman Kumar | [8ea2a0] config package complete |
Create and store PHP app configuration files (like site url, timezone, db credentials, etc.) in any of the bellow
formats:
composer require dikki/config
First, ensure that you have a config folder in your project. Add all your config files in this folder.
use Dikki\Config\Config;
// 1. create instance of Config class
// 2. pass the parser you want to use to the constructor [YamlParser, JsonParser, IniParser, PhpArrayParser]
// 3. pass the path to the config folder to the constructor or the file path to the config file
$config = new Config(new \Dikki\Config\YamlParser(__DIR__ . '/config'));
// get a config value (dot notation is supported)
echo $config->get('app.timezone');
OUTPUT: UTC