All configuration files are located in your
By default, framework needs these configs in your configs folder:
configs/application.php - paths, environment, log
and class aliases
configs/cache.php - cache drivers and their options
configs/database.php - database drivers and their options
configs/mail.php - mail drivers and their options
configs/session.php - session options
All config files should return the associative
<?php /* Lets assume this file is named configs/site.php */
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
'key4' => 'value4'
Fetching should be always performed using
method. That method accepts two parameters from which both of them
are optional. If you don't pass anything, then you'll get the whole
If you want to get the array from the example above, then run this:
If you want to get value of
key1 from the example above, then run:
echo Application::getConfig('site', 'key1'); // prints "value1"
Once you fetch the config, it will be stored in
class so next time you fetch it, it will be taken from request scope
and not again from file. That means that you can freely run
Application::getConfig() as many times as you want.
If you're running long jobs with this framework (such as jobs in CLI), then you might have a need to reload config that was already loaded into memory. In that case, please run:
And then run
So, to create your own config, make file named
your-config-name.php, save it in your
and make sure that this file returns array by
the example above.
After you created your config file, you'll be able to run
Application::getConfig('your-config-name') from anywhere.
|How Framework Works||Project Structure|