talesoft / tale-config
Lightweight configuration interfaces and utilities
Installs: 35 902
Dependents: 7
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.0
- talesoft/tale-factory: ~0.1
Suggests
- symfony/yaml: for YAML-configuration
- talesoft/tale-dom: for XML-configuration
This package is auto-updated.
Last update: 2024-12-10 08:56:31 UTC
README
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 } }