A Tale Framework Component
A small configuration utility library. It supports different adapters and a few utilities to handle option arrays and configurable objects
Install via Composer
composer require "talesoft/tale-config:*"
composer install
use Tale\ConfigurableInterface;
use Tale\ConfigurableTrait;
class DbConnection implements ConfigurableInterface
{
use ConfigurableTrait;
public function __construct(array $options = null)
{
$this->defineOptions([
'host' => 'localhost',
'user' => 'root',
'password' => '',
'encoding' => 'utf-8',
'databases' => [
'db1' => 'database_1',
'db2' => 'database_2'
}
], $options);
var_dump($this->getOptions()); //The current options
var_dump($this->getOption('databases'); //['db1' => 'database_1', 'db2' => 'database_2']
var_dump($this->getOption('databases.db1'); //database_1
var_dump($this->getOption('databases.db2'); //database_2
}
}