Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      Configuration

      Configurating your application

      Table of Contents

      Introduction

      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.

      However, Lion has a mechanism to organize the configuration in multiple files. This capability eases the configuration maintainment.

      Let see it with an example:

      1. <?xml version "1.0" standalone="yes"?>
      2. <configuration>
      3.  
      4.   <include>config/settings.ini</include>
      5.   <include>config/controllers.xml</include>
      6.   <include>config/error_codes.xml</include>
      7.   <include>config/i18n.xml</include>
      8.   <include>config/context.xml</include>
      9.   <include>config/model_services.xml</include>
      10.   <include>config/routes.xml</include>
      11.   <include>config/security.xml</include>
      12.   <include>config/views.xml</include>
      13.   <include>config/ui_components.xml</include>
      14.   <include>libs/components/.../config.xml</include>
      15.   <include>libs/plugins/.../config.xml</include>
      16.   
      17. </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.

      i.e., if we have this config.xml file:

      1. <?xml version "1.0" standalone="yes"?>
      2. <configuration>
      3.  
      4.   <configuration-directives>
      5.     <configuration-basedir>config</configuration-basedir>
      6.   </configuration-directives>
      7.   
      8.   <include>config://i18n.xml</include>
      9.   
      10. </configuration>
      and this i18n.xml file located in the config directory:
      1. <?xml version "1.0" standalone="yes"?>
      2. <configuration>
      3.   
      4.   <supported-languages>
      5.     <language>en</language>
      6.   </supported-languages>  
      7.   
      8. </configuration>
      it has the same effect than to have just the following config.xml file:
      1. <?xml version "1.0" standalone="yes"?>
      2. <configuration>
      3.  
      4.   <configuration-directives>
      5.     <configuration-basedir>config</configuration-basedir>
      6.   </configuration-directives>
      7.   
      8.   <supported-languages>
      9.     <language>en</language>
      10.   </supported-languages>  
      11.   
      12. </configuration>

      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.


      Default configuration sections