Generates a set of php configuration classes from a supplied xml file. You can then access your configuration values very quickly without having to parse the xml file on every request.
This class can be used to generate a PHP class from an XML file. The element (tag) names become property names and the text contained in the elements becomes the property's value. It also supports nested elements.
If the generated php file is older than the xml file, it is re-generated using the data in the newer xml file.
For example, this xml file:
<config>
<database>
<connString>This is my connection string</connString>
</database>
</config>
Would be accessed in php as follows (after the ConfigurationLoader.update method had been called:
$config = new config();
echo $config->database->connString;
This class also supports array types using the <item> element inside an element whose type attribute is set to "array". Please read the documentation and see example xml files for more details.
Once you have your configuration classes you can get or set the values as required. |