New Configuration Factory Possible Features

Once the new Configuration is finish, it would be completely possible to have a SQLite or XML or CONF configuration referencing the MySQL access data and then using MySQL for the rest of the information. The main factory class will check every configuration for the value (this part hasn’t been finished yet), so it is totally possible for multiple names and sections to come up, but that will be worked out by giving a name to each of the configuration when loaded.

$config->load(‘/path/to/sqlite/database.sqlite’, ‘site’);
$config->load(‘/path/to/xml/mysql.xml’, ‘database’);

So there are two configuration files loaded with the name ‘database’, and ‘site’. These must be unique and since there shouldn’t be a great deal of the configuration files and usage, that requirement shouldn’t be unreasonable.

So you could access them by

$config['mysql']['username']; // From mysql.xml
$config['mysql']['host']; // From mysql.xml

$config['template']['default']; // From database.sqlite

or you could do

$config['database']['mysql']['username'];
$config['site']['template']['default'];

In which case that there is the same name as the configuration name, then the configuration name will be used first to see if the section exists, if not, then it will use the first usage without.

For $config['mysql'] see if name is a placeholder for the configuration file? No, then it must be a section, return that the section that it exists in.

For $config['database']['database'], does the name exist for the configuration file? Yes, does the section exist? Yes, then return the section.

What if it doesn’t exist? Does the next section exist (['mysql']), yes then ignore the last section. If not then create the section.

Other Methods

I’ll probably have a lot more functions in place so that the programmer can do accurate checking and command the classes in the exact action to take and not guess.

if($config['database']['section']->exists() === false) $config['database']['section']->create();

if($config['database']['section']->isUnique() === false) $config['database']['section']['name'] = value;

It would take a lot more coding, but I believe the configuration class will offer a great deal of features and options over the other configuration available.

Caching

There is still no internal caching, but I’m currently working on that issue. If the configuration class is fast enough, then I don’t think I’ll include it, but it will most likely be a 0.7 issue anyway even if it isn’t needed. If it is needed, then I’ll have to add it to the class and it will most likely be an array in the main factory class.

By using the Data Store, I hope to have the ability to add it in. Currently, My mind is spent on just trying to create an intelligent Configuration Factory that allows for multiple configuration files. The idea of keeping the instance of the Data Store in memory is a foreign concept to me, but I may an idea on how to do it Using the Data Store.

Possibly Related Posts:


Comments are closed.