PHP code example of talesoft / tale-config
1. Go to this page and download the library: Download talesoft/tale-config library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
talesoft / tale-config example snippets
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
}
}