Wallogit.com
2017 © Pedro Peláez
Notice This is designed for Yaf, if you're using other framework, leave it., (*1)
Bootstrap
class Bootstrap extends Yaf\Bootstrap_Abstract
{
public function _initLoader(Dispatcher $dispatcher)
{
require __DIR__ . '/../vendor/autoload.php';
}
}
composer require lovelock/yafconf, (*2)
If you don't like composer, you can require it from your local directory as well. You may put it in your library path as you wish., (*3)
This project relies on two global constants, (*4)
CONF_PATH
This tells Conf where to find the .ini files., (*5)
APP_ENV
This tells Conf what directives to find in .ini files., (*6)
Conf::get($key)
$key MUST be . seperated. I.E, a dot is used as a seperator of the configuration path and its real key. e.g:, (*7)
Conf::get('database.database.host')
will find the database.ini in CONF_PATH and fetch the value of the key database.host in the configuration., (*8)
It supports array as well, which means, if your configuration file is like this:, (*9)
; database.ini [product] database.dbtype=mysql database.host=127.0.0.1 database.port=3306 database.dbname=ttlive database.user=root database.password=root database.charset=utf8 [dev : product] database.host=192.168.1.103
Conf::get('database.database') will give you an array, (*10)
array (
'dbtype' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
'dbname' => 'ttlive',
'user' => 'root',
'password' => 'root',
'charset' => 'utf8',
)
Further more, if you set the constant APP_ENV = dev, and the result array would be, (*11)
array (
'dbtype' => 'mysql',
'host' => '192.168.1.103',
'port' => '3306',
'dbname' => 'ttlive',
'user' => 'root',
'password' => 'root',
'charset' => 'utf8',
)