0.1.0 2013-09-25 13:34 UTC


A simple reader of .ini configuration files.

##Install You may install the phpConfig with Composer (recommended) or manually.

##Usage This example assumes you are autoloading dependencies using Composer or any other PSR-0 compliant autoloader.

//Create a new PhpConfig
$config = new \PhpConfig\PhpConfig(); 

//Add any ini resources
//You can add many resource in a single line
$config->addResource('config.ini', 'config2.ini' );

//Load the resources and produce the configuration array
//If the same key is present in many resources, the last one will be preserved.

//Get the configuration array
$myConfiguration = $config->getConfig();

To deny browser access to the .ini files add this directive in .htaccess

<Files *.ini> 
    Order deny,allow
    Deny from all

By example consider this ini files:


param1 = GlobalA1
param2 = GlobalA2


param1 = LocalA1
param3 = LocalA3

param1 = LocalB1
param2 = LocalB2

With this code:

//Create a new PhpConfig
$config = new \PhpConfig\PhpConfig(); 

//Add resources
$config->addResource('Global.ini', 'Local.ini' );

$myConfiguration = $config->getConfig();

you get this array:

    [param1] => LocalA1,
    [param2]=> globalA2,
    [param3]=> LocalA3
    [param1] => LocalB1,
    [param2]=> LocalA2

##License The phpConfig is released under the MIT public license