PHP
  Home arrow PHP arrow Page 3 - Easy Application Configuration With patConfiguration
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Easy Application Configuration With patConfiguration
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2003-01-29


    Table of Contents:
  • Easy Application Configuration With patConfiguration
  • Plug And Play
  • Your Friendly Neighbourhood Spiderman
  • Anatomy Class
  • Version Control
  • The Write Stuff
  • Speaking Native
  • Not Your Type
  • When Time Is Money, Recycle!
  • Cache Cow
  • Link Zone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Easy Application Configuration With patConfiguration - Your Friendly Neighbourhood Spiderman
    ( Page 3 of 11 )

    Now that the hard sell is over and you're (hopefully) all set up with patConfiguration, let's take a simple example to see how it works.

    Consider the following simple configuration file:


    <?xml version="1.0" encoding="UTF-8"?> <configuration> <path name="mail"> <configValue name="from-name" type="string">Peter Parker</configValue> <configValue name="from-address" type="string">spider.man@roof.top.com</configValue> </path> </configuration>
    The XML file above contains configuration data in a format that is understood by patConfiguration. As you can see, a patConfiguration-compliant configuration file must conform to the standard rules of XML markup, and must contain a <configuration> root element. Configuration values can be grouped together under this root element using <path> elements, with every variable-value pair represented by a <configValue> element.

    Variable-value pairs are accessed by drilling down the tree of <path> elements until the desired node is reached. For example, to access the value of the email address

    spider.man@roof.top.com
    in the configuration file above, I would use the path

    mail.from-address.
    patConfiguration allows you to nest <path> elements to any depth - the following is a perfectly valid configuration file:

    <?xml version="1.0" encoding="UTF-8"?> <configuration> <path name="application"> <configValue name="name" type="string">SomeApp</configValue> <configValue name="version" type="string">2.3</configValue> <path name="window"> <configValue name="height" type="int">600</configValue> <configValue name="width" type="int">500</configValue> <path name="list"> <configValue name="maxItems" type="int">5</configValue> </path> </path> </path> </configuration>
    You can even link the values in a configuration file with each other via the <getConfigValue> element - consider the following example, which uses the application name and version number to dynamically create a variable containing the window title:

    <?xml version="1.0" encoding="UTF-8"?> <configuration> <path name="application"> <configValue name="name" type="string">SomeApp</configValue> <configValue name="version" type="string">2.3</configValue> <path name="window"> <configValue name="height" type="int">600</configValue> <configValue name="width" type="int">500</configValue> <configValue name="title" type="string"> <getConfigValue path="application.name" /> <getConfigValue path="application.version" /> </configValue> </path> </path> </configuration>
    The variable-value pairs in this configuration file can be read and manipulated by patConfiguration in the context of a PHP application. Let's look at that next.

     
     
    >>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT