Skip to content

Talesoft/tale-config

Repository files navigation

Tale Config

A Tale Framework Component

What is Tale Config?

A small configuration utility library. It supports different adapters and a few utilities to handle option arrays and configurable objects

Installation

Install via Composer

composer require "talesoft/tale-config:*"
composer install

Usage

The ConfigurableTrait

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
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages