Search This Blog

Wednesday, November 7, 2007

Process XML Configuration Files with PHP

As a general rule, when you develop any reasonably-complex piece of
software, it's a good idea to take time to identify the product's key
configuration variables, and then separate these from the standard
variable namespace and place them in a separate area. With this process,
you can create a centralized repository of application configuration
information and simplify the task of modifying the product to work in
different environment. It can also help increase a developer's
familiarity with, and understanding of, the key pieces of information
needed to get the product up and running. Traditionally, configuration
variables are stored in one (or more) configuration files. XML provides
a convenient, easy-to-use expression language for an application's
configuration files. To extract this information into a PHP script can
sometimes pose a challenge. That's where the XJConf for PHP package
comes in: It provides an API to read XML-encoded information and
directly use it to configure PHP data structures like scalars, arrays
and PHP objects. This article introduces the package and demonstrates
some useful real-world applications of its usage, including configuring
complex class trees and building a Web-based configuration interface.
The XJConf package provides an easy-to-use, flexible API that reads
XML-formatted configuration files and converts the values found therein
into PHP data structures. In addition to simple string and numeric
values, it also supports the use of arrays and objects, and includes
built-in intelligence to automatically configure newly-instantiated
objects through setter methods. More Information See also the XJConf for PHP Web site: Click Here

No comments: