Config::parseConfig() – Parse datasource contents


require_once 'Config.php';

mixed &Config::parseConfig ( mixed $datasrc , string $configType , array $options = array() )


This method will parse the datasource given and fill the root Config_Container object with other Config_Container objects. It will return a reference to the root Config_Container object or a PEAR_Error if something went wrong.


mixed $datasrc

Datasource to parse. For most containers, it is a file path. For the PHP array parser, it can be an array too.

string $configType

Type of configuration to parse

array $options

Options for the parser

Return value

object - a reference to Config_Container object


Possible PEAR_Error values
Error code Error value Meaning Solution
PEAR_ERROR_RETURN "Configuration type '$configType' is not registered in Config::parseConfig." The config type must be registered for use by Config. Use one of the standard config types, or register your custom container using Config::registerConfigType

Other errors may be returned from the parser for the specific container you're using.


This function can not be called statically.


Using parseConfig()

= new Config();
$root =& $config->parseConfig('/path/to/file.php''phparray'
'name' => 'conf'));
Returns TRUE if container is registered (Previous) Registers a custom Config container (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

Note by:
$conf = new Config;
$root = $conf->parseConfig($file, 'XML');

$conf = new Config;
$root = $conf->parseConfig($file, 'XML');

these statements will eat too much memory. even unset() won't be able to free some memory. this produces fatal memory errors while parsing large xml files in a repeated loop.
Note by:
Ahoy, a quick reference - values for the config type can be (as per v 1.21): apache, genericconf, inifile, inicommented, phparray, xml.