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.

Writing a config file with custom options

<?php
require_once 'Config.php';

$conf = new Config();
$root $conf->getRoot();
$root->createComment('Demo config file with GenericConf container');
$root->createDirective('openLastFile'true);

$root->createBlank();
//GenericConf does not support sections, but section contents are serialized
// into the main config namespace
$dbsect $root->createSection('database');
$dbsect->createDirective('host''db-server.example.org');
$dbsect->createDirective('name''demo-db');

$r $conf->writeConfig(
    
'generic-conf-write.txt',
    
'genericconf',
    array(
        
'comment' => '#',
        
'equals'  => '=>',
    )
);
if (
PEAR::isError($r)) {
    echo 
$r->getMessage() . "\n";
}
?>

Generated file

#Demo config file with GenericConf container
openLastFile=>1

host=>db-server.example.org
name=>demo-db
Apache (Previous) IniCommented (Next)
Last updated: Wed, 16 Apr 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.