Configuration

The Configuration classes allow you to maintain common settings/option separetly from your application code.

PHP Configuration

This solution allows you to create a normal PHP file that declares a special multi-dimensional array containing the configuration required by the framework and your application.

Example PHP Config

<?php
$config = array(
	'DBDSN' => array(
	    'phptype' => 'mysql',
	    'hostspec' => 'localhost',
	    'database' => 'database_name',
	    'username' => 'johndoe',
	    'password' => 'xxxx',
	),
	'LIB' => '../../',
	'APP' => './app/',
	'BASE' => 'http://www.mydomain.com/',
);
?>

This file must be passed to a new A_Config_Php instance like so.

$Config = new A_Config_Php('path/to/config/file.php');
$Config->loadFile();

Remember, this file is imported with include(), so you can put other configuration related PHP here also. But wait, there's more: you can also put custom settings into the main config array that can be read from the A_Config_Php object by your application.

INI Configuration

INI gives you a very neat, standardized configuration solution. INI is basicly a text file specifically formatted to be parsed for data.

Example INI Config

[production]
phptype = mysql
hostspec = 127.0.0.1
database = skeleton
username = skeleton
password = skeleton
ERROR = E_ALL

[development]
one = 4
two = 5
three = 6
ERROR = E_ALL|E_STRICT

This file must be passed to a new A_Config_Ini object. The syntax is the same as PHP. This method can use custom option parameters.

Other Configuration Classes

Config also supports configuration with XML and YAML; these are used in the same way as the ones laid out here. Please refer to the PHPDocs for more info.

All the rest should be removed, to reduce documentation maintainance needed.







XML Configuration

Needs explanation paragraph

Example XML config file.

<?xml version="1.0" encoding="UTF-8"?>
<xml>
	<a0>North by Northwest</a0>
	<Casablanca>
		<b0>Jane Doe</b0>
		<b1>77</b1>
	</Casablanca>
	<Notorious>
		<name>Jane Doe</name>
		<age>77</age>
	</Notorious>
	<name>John Smith</name>
	<age>33</age>
	<a1>milk</a1>
	<a2>pumpkin pie</a2>
	<a3>eggs</a3>
	<a4>juice</a4>
	<color>Lemon yellow</color>
	<size>100</size>
</xml>

The XML file must be passed to a new A_Config_Xml instance just like PHP.

YAML Configuration

Needs explanation paragraph

Example YAML Configuration

--- # Favorite movies, conventional  block format uses a dash to begin a new item in list 
- North by Northwest
-
	- Jane Jones
	- 44

Casablanca :
	- Jane Doe
	- 77
Notorious : 
	name: John Doe
	age: 66

--- # Block
name: John Smith
age: 33

--- # Shopping list, optional inline format is delimited by comma+space and enclosed in brackets.
[milk, pumpkin pie, eggs, juice]

--- # Inline
{color: "Lemon yellow", size: 100}

Again, this must be passed to a new A_Config_Yaml instance just like the other configuration objects.