Why INI Files
THIS uses INI files for many aspects of configuration. Currently, we have at least six (each additional theme created can add one or two more). All INI files are described in detail within them or within their corresponding module.
This document provides an overview of why we decided to use INI files for configuration. We chose the INI format, but any other separate data file, be it JSON or XML or whatever, could be used to accomplish the same thing.
A few of our INI files are going to be converted to PHP format.An INI file is one of the simplest ways to store user configuration data; so common is INI file usage that we need not provide any examples beyond stating that PHP provides a function to parse INI files, and that PHP itself is configured by an INI file.
While an SQL based database is incredibly useful, it is as ill-suited for handling only a few dozen configuration values, as an INI file is ill-suited for storing large amounts of distributed data.
An INI file can be a good choice for many reasons:
- Human readable.
- A universally understood format.
- Editable by any text editor and/or command line tools.
- Transferable through any medium.
- Easily stored within any medium — even a database.
An INI file can be considered a self-creating database. One can use the simplest of text editors to write many lines of data, and with one function call turn that data into an associative array — something that cannot be done so simply with any sort of database.
An INI file is also suitable for remote configuration. Storing basic configuration data in a database requires a large "front end" application to support it, whereas with basic configuration in a text file one can use many simple ways to change the data — SSH, FTP, cPanel, etc.
The ability to configure the core (or "start up") code by remote, without having to use the program itself, is why we chose an INI file for basic configuration.
We tested many Blog and CMS applications and all of them had one common aspect: The requirement of a populated MySQL database, with an extensive set-up and installation process before you could even see what the application looked like. THIS means to change that.
Php Ini Files
Some INI files are really PHP files, which means instead of something this:
[section] key = value
there is something like this:
$data['section'] = array(
'key' => 'value'
);
These files, since they are editable online by Admin are loaded in a way that evaluates them for possible errors, isolating parse errors so that the code still runs. Currently these files are for the post translations and the theme templates.
Notes
1. PHP's parse_ini_file()
function imposes restrictions on key names and requires some values to be escaped. We have a version that does not have these restrictions (and has a few enhancements), but we do use parse_ini_file()
in a few cases.
2. Not having to have a MySQL database to test the application is slightly more complicated than just having a few INI files though.