The premise for the Lion configuration system is simple: to provide developers with a consistent manner for storing and reading configuration information.
The Lion configuration system features an extensible infrastructure opened for extension, providing the following benefits:
Configuration information is allowed to be stored in several formats (XML, .ini files, ...) as well as in multiple configuration files. In that sense, Lion offers a flexible way to organize the configuration within an application.
Configuration information is cached once it has been parsed and transformed. So there are not performance penalties in that sense.
Lion configuration system is extensible. You can define new configuration parameters and write configuration section handlers to process them.
Lion protects configuration files from outside access to prevent direct browser access to configuration files.
The main configuration file
The first configuration file that Lion reads is one located at /app/config.xml.
The application context directory is the /app directory. However, lion support multiple contexts within the same application.
See the Context/Context.pkg section for more information about contexts in lion.
However, Lion has a mechanism to organize the configuration in multiple files. This capability eases the configuration maintainment.
Let see it with an example:
<?xml version = "1.0" standalone="yes"?>
<configuration>
<include>config/settings.ini</include>
<include>config/controllers.xml</include>
<include>config/error_codes.xml</include>
<include>config/i18n.xml</include>
<include>config/context.xml</include>
<include>config/model_services.xml</include>
<include>config/routes.xml</include>
<include>config/security.xml</include>
<include>config/views.xml</include>
<include>config/ui_components.xml</include>
<include>libs/components/.../config.xml</include>
<include>libs/plugins/.../config.xml</include>
</configuration>
In this file we can see a bundle of include directives. Those directives let Lion know which other files belong to the configuration.
Configuration directives
The configuration-directives section contains the directives that the __ConfigurationLoader will follow to parsing the configuration settings.
In this section we can define:
configuration-basedir directive, which is the directory where the configuration files will be located by default. In fact, this is the first directory that lion search when a configuration file is specified by ussing the config protocol, i.e. config://controllers.xml.
section-handler directives, which allow us to extend the configuration system by adding custom section handlers.
See the Section Handlers section for more information.
Include sections
The use of include allows us to define which other files are part of the configuration settings.
Internally, lion will get the content of each included file (once it has been transformed as a tree) and will put in the tree location where the include section resides.
Note that because the supported-languages section is a child section of the configuration section, it is included within this section in the main configuration file.
One of the most important aspects to have into account is the fact that Lion does not compose a single configuration file when reading the include sections. It just build multiple trees by ussing the configuration classes designed for that purpose.
This feature allow us to have files in different formats, structures and natures within the same context.