Developer Blog

  • Blog
  • /
  • Updates to configuration file handling and Email module
By Dracony on 10 January 2013

The simplistic configuartion structure with having a single config.php while easy to maintain is not wel suited for modularity, so it has received some changes. Now instead of putting your configuration options in /application/config.php you create files inside the /application/config/ folder.   Because of the cascading file system you may also keep those files inside modules. For example you can move the file from /application/config/database.php to /modules/database/config/database.php with no changes to the code. to better describe the configuration files let’s assume that we want to describe a magical forest with a config. It will look like this:

1
2
3
4
5
6
7
8
9
// /application/config/forest.php
<?php
return array(
    'trees' => 8,
    'dwellers' => array(
            'fairies' => 8,
            'pixies' => 10
        )
    );

and you can access these options like this (notice that the first part of the option name is the name of the file):

1
2
3
4
5
6
7
8
9
//Getting an option
$num_fairies=Config::get('forest.dwellers.fairies');

//Setting or updating an option
$num_fairies=Config::set('forest.dwellers.fairies',15);

//Writing options back to config file
$num_fairies=Config::write('forest');

Using it in this way can help better organize your configuration files.

Also a new Email module has been added which allows you to send emails using Swift Mailer library.

comments powered by Disqus