Login   Register  
PHP Classes
elePHPant
Icontem

ezphpconfig: Converts xml config file into a set of php classes

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2008-05-23 (6 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,149 All time: 3,016 This week: 1,521Up
Version License PHP version Categories  
ezphpconfig 0.4GNU General Public Lice...5XML, PHP 5, Code Generation, Configur...
Description Author  

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.

Innovation Award  
PHP Programming Innovation award nominee
April 2008
Number 8


Prize: One book of choice by Packt
XML is often used by humans to store information that can easily be parsed by computer programs, like for instance application configuration options.

However, XML parsing is often a process that consumes too much CPU and memory when parsing many documents or the same document many times.

This class provides a solution to override the overhead of repeatedly parsing XML configuration files. It creates a PHP class file with variables set to the configuration values retrieved from the XML file.

This way the XML file does not have to be parsed in all requests on which its information is needed. The speedup can be further optimized by using a PHP caching engine extension, as the generated PHP class does not need to be parsed and compiled again.

Manuel Lemos
Picture of David Wainwright
Name: David Wainwright <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom
Age: 40
All time rank: 195885 in United Kingdom United Kingdom
Week rank: 1826 Up75 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Accessible without login Plain text file config.xml Doc. example config file
Plain text file ConfigurationLoader.class.php Class class file
Accessible without login Plain text file COPYING Lic. license
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file example.xml Data example xml file
Accessible without login Plain text file README Doc. Setup Instructions

 Version Control Unique User Downloads Download Rankings  
 0%Total:1,149All time:3,016
 This week:0This week:1,521Up