Home arrow PHP arrow Page 10 - Easy Application Configuration With patConfiguration

Cache Cow - PHP

Tired of handcrafting configuration file manipulation tools for your Web application? Save yourself some time with patConfiguration, a PHP class designed to assist developers with reading, writing and maintaining application configuration files.

TABLE OF CONTENTS:
  1. Easy Application Configuration With patConfiguration
  2. Plug And Play
  3. Your Friendly Neighbourhood Spiderman
  4. Anatomy Class
  5. Version Control
  6. The Write Stuff
  7. Speaking Native
  8. Not Your Type
  9. When Time Is Money, Recycle!
  10. Cache Cow
  11. Link Zone
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 1
January 29, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Normally, patConfiguration parses your XML configuration file every time you need to load configuration data; this is expensive, in terms of both time and processor cycles. In these situations, you can obtain a performance improvement by using patConfiguration's built-in cache, which uses a serialized representation of the XML data to speed up load time.

Using a cache is pretty easy - consider the following example, which demonstrates how:


<? // include class require("patConfiguration.php"); // create patConfiguration object $conf = new patConfiguration; // set config file locations $conf->setConfigDir("config"); // set cache locations $conf->setCacheDir("cache"); // read config file $conf->loadCachedConfig("config.xml"); // get configuration values print_r($conf->getConfigValue("application.version")); ?>


Using the cache is thus simply a matter of setting a cache directory and using the loadCachedConfig() method instead of the parseConfigFile() method. If the file does not already exist in the cache, patConfiguration will locate it, read and serialize it, and use the serialized version in all subsequent calls. When the data in the original file changes, this change is detected by patConfiguration and the cache is updated with the new data.

Finally, patConfiguration also comes with a number of extensions to simplify integration with, and configuration of, other pat classes - extensions are currently available for the patTemplate, patUser and patDbc classes, and the source distribution comes with numerous examples of how they may be used. I'm not going to get into the details here, but you should certainly take a look at this once you're comfortable with the basics of using patConfiguration.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: