vaibhavpandeyvpz / kunfig
Helper library to easily merge & use multiple configuration files.
1.0
2017-01-22 11:22 UTC
Requires
- php: ^5.3 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0
This package is auto-updated.
Last update: 2024-10-07 00:04:51 UTC
README
Helper library to easily merge & use multiple configuration files.
Install
composer require vaibhavpandeyvpz/kunfig
Usage
<?php /** * @desc Create a Kunfig\Config instance with some initial values * passed into constructor. */ $config = new Kunfig\Config(array( 'database' => array( 'host' => 'localhost', 'port' => 3306, 'charset' => 'utf8mb4', ), 'debug' => false, )); // Get a value $host = $config->database->host; // Set a value $config->database->host = 'xxxxxxxxxxxxx.xxxxxxxxxxxxx.us-west-2.rds.amazonaws.com'; $override = new Kunfig\Config(array( 'database' => array( 'name' => 'test', 'user' => 'root', 'password' => null, ), )); /** * @desc You can mix two Kunfig\ConfigInterface; the latter one * will override values in the original one. */ $config->mix($override); $pdo = new PDO( "mysql:host={$config->database->host}:{$config->database->port};dbname={$config->database->name}", $config->database->user, $config->database->password );
License
See LICENSE.md file.