previousEditing a configuration (Previous) (Next) Config::Confignext

View this page in Last updated: Tue, 02 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Available Containers

Available Containers – Supported formats

Available Containers

Apache

Parses and saves Apache configuration files. No options are provided by this container.

GenericConf

Generic configuration files. The equals, comment start and new line characters in the parser can be customised to match your preferred configuration format.

Available Options
Option Data Type Default value Description
"comment" string "#" The character that signifies the start of a comment.
"equals" string ":" The character that separates keys from values.
"newline" string "\" The character that signifies that a value continues across multiple lines.

IniCommented

Parses standard INI files, maintaining comments within the file. No options are available for this container.

IniFile

Parse standard INI files using PHP's in built parse_ini_file(). Does not read in comments. No options are available for this container.

PHPArray

Parses PHP Array structures. Can read from a PHP Source file or from an in memory array. Due to technical limitations, this container does not parse blank lines or comments when reading from a configuration file, therefore any information contained within PHP comments will be lost.

Available Options
Option Data Type Default value Description
"name" string "conf" The name to use for the root configuration variable, both when parsing and writing PHP source files.
"useAttr" boolean TRUE Controls whether attributes are parsed and saved.

Since config files containing php arrays are just included using the standard php methods, code comments and structure will be lost when saving.

PHPConstants

Parses a set of PHP define() from a PHP source file. Comments are maintained by this container, although blank lines will be lost. There are no options for this container.

XML

Parses a XML file using XML_Parser.

Available Options
Option Data Type Default value Description
"version" string "1.0" The XML version to use.
"encoding" string "ISO-8859-1" The content encoding to use when parsing and storing data.
"name" string "conf" As with PHPArray, this defines the name of the global configuration root.
"indent" string " " The character used for indentation when writing the XML document, if any. By default, two spaces are used.
"linebreak" string "\n" The line-breaking character(s) to use when writing the XML document.
"addDecl" boolean TRUE Controls whether the XML declaration is added to the start of the XML document.
"useAttr" boolean TRUE Controls whether attributes are parsed and saved.
"isFile" boolean TRUE If TRUE, the first argument to parseConfig() will be taken as the file name for the XML file to load. If FALSE, the argument will be taken as the XML data itself and parsed accordingly.
"useCData" boolean FALSE Controls whether data is enclosed in CDATA blocks.

previousEditing a configuration (Previous) (Next) Config::Confignext

Download Documentation Last updated: Tue, 02 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: awgrover@msen.com
Here's some example config-file formats for PHP 5.1.2, Pear 1.6.2 Config 1.10.11.

Using the example code from this package's Introduction (../package.configuration.config.intro.php),
adding a blank-line and comment, and using defaults.

Apache
Described in http://httpd.apache.org/docs/2.0/configuring.html

<conf>
<DB>
type mysql
host localhost
user root

# this is a comment (after a blank line)
pass root
</DB>
</conf>

GenericConf
No sections. Apparently simple "key:value" lines.

type:mysql
host:localhost
user:root

#this is a comment (after a blank line)
pass:root

IniCommented
Apparently the Windows ini format
Useful reference: http://search.cpan.org/~wadg/Config-IniFiles-2.38/IniFiles.pm#FILE_FORMAT

[conf]
[DB]
type = mysql
host = localhost
user = root

;this is a comment (after a blank line)
pass = root

PHPArray
A bunch of array assignments. PHP code. Presumably does "include" or "eval". Arbitrary code probably possible.

<?php
    $conf
['conf']['DB']['type'] = 'mysql';
    
$conf['conf']['DB']['host'] = 'localhost';
    
$conf['conf']['DB']['user'] = 'root';

    
// this is a comment (after a blank line)
    
$conf['conf']['DB']['pass'] = 'root';
    
?>


PHPConstants
A bunch of "define()". Does not recognize/use sections. PHP code. Presumably does "include" or "eval". Arbitrary code probably possible.

<?php

    
/**
     *
     * AUTOMATICALLY GENERATED CODE -
                    DO NOT EDIT BY HAND
     *
    **/

    //
    // conf
    //

    //
    // DB
    //
    
define('type''mysql');
    
define('host''localhost');
    
define('user''root');

    
// this is a comment (after a blank line)
    
define('pass''root');

    
?>


XML
Straight-forward nested xml. Does not respect blank-lines.

<?xml version="1.0" encoding="ISO-8859-1"