propelorm/Propel2 — pull request #527 by cristianoc72 (2014-01-17 13:49:25+00:00)
Title: [WIP] Configuration system refactor

See issue #285.

### Basic ideas ###
- Reorganize the configuration properties in a more rational hierarchy
- Support for multiple formats
- Validate configuration

### Implementation details ###

Some of the following points should be discussed.

- Based on [Symfony Config Component](http://symfony.com/doc/current/components/config/index.html)
- Support for `.php, .ini, .json, .yaml, .xml` formats.
- Ini file loader accepts both `.ini` and `.properties` files.
- Inside ini file, we can define a hierarchy in standard way (with sections and array definitions) or in a "nested" way, inspired by [Zend Framenwork Config](http://framework.zend.com/manual/2.2/en/modules/zend.config.reader.html).
- Ability to define some parameters, in any configuration format, delimited by `%` (see `Symfony\Component\DependencyInjection\ParameterBag` class).
Example:

``` yaml
# yaml
database:
adapter: mysql
host: localhost
dsn: %adapter%:host=%host%
```
becomes:

```php
// php
array(
'database' => array(
'adapter' => 'mysql',
'host' => 'localhost',
'dsn' => 'mysql:host=localhost
)
);
```
- I've put all new classes in `Propel\Common\Config` namespace. I've choosen `Propel\Common` because, theoretically, configuration system can be used both at generation and runtime, even if, for the most part, is used at generation time.
- I supposed to define a single configuration file, named `propel-config.ini` (or .yaml or some other supported format) which should be located in project root directory or in a sub-directory named "conf" or "config" (we can choose something else). This file also replace `runtime.conf` and `buildtime.conf`.
- Default configuration, shipped with Propel, is placed in `tools/Generator/default-config.yaml` file (may be it could be better `tools/Config/default-config.yaml`). Default properties can be override by project configuration, which can be override by options passed to command line.

### Roadmap ###

- [x] Step 1: add new classes and relative tests
- [ ] Step 2: move all default options from command classes to `default-conf.yaml` and implement `Propel\Common\Config\PropelConfiguration` class to validate it via TreeBuilder. Remove all not more used options and define a better property structure.
- [ ] Step 3: refactor all those classes using configuration.
- [ ] Step 4: update documentation

Each step can be merged separately.