HomePHP Page 8 - Easy Application Configuration With patConfiguration
Not Your Type - 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.
You'll remember, from a couple pages back, that patConfiguration supports a number of different data types for its configuration variables. This variable type can be set via the setConfigValue() method, and currently can be any one of "string", "integer", "boolean", "array" and "float".
Here's an example which demonstrates how strings, integers and Booleans work:
<?
// include class
require("patConfiguration.php");
// create patConfiguration
object
$conf = new patConfiguration;
// set config file locations
$conf->setConfigDir("config");
//
set config values
$conf->setConfigValue("screen.width", 500, "integer");
$conf->setConfigValue("font.face",
"Verdana", "string");
$conf->setConfigValue("window.toolbar.visibility", true,
"boolean");
// write file
$conf->writeConfigFile("config.xml", "xml", array("mode"
=> "pretty"));
?>