Config
, (*1)
Config library can be used to store configuration options, which can be used later in the application. The set
, get
, has
and remove
methods as well as \ArrayAccess
can be used to control the configuration options. For easy usage dot notation is supported to access nested arrays., (*2)
The source code is very easy to understand and can be extended to support more functionality when needed., (*3)
Installation
Via Composer, (*4)
$ composer require joebengalen/config
Usage
<?php
require_once 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Instantiate the config object.
$config = new \JoeBengalen\Config\Config();
// Load a php config file info the config object.
$config->load(__DIR__ . DIRECTORY_SEPARATOR . 'config.php');
// Set some more configurations.
$config->set([
'database.host' => '127.0.0.1',
'database.user' => 'root',
]);
// Show an array of all database configurations
var_dump($config->get('database'));
Testing
PHPUnit is used for testing. The source code is 100% covered., (*5)
There is an phpunit.xml.dist
file with some default settings for phpunit., (*6)
$ phpunit
Note: phpunit is not included. The command assumes phpunit is installed globally., (*7)