2017 © Pedro Peláez
 

library phpconfig

Load INI configuration files

image

sigjlr/phpconfig

Load INI configuration files

  • Thursday, October 10, 2013
  • by sigjlr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

phpConfig

A simple reader of .ini configuration files., (*1)

Install

You may install the phpConfig with Composer (recommended) or manually., (*2)

Usage

This example assumes you are autoloading dependencies using Composer or any other PSR-0 compliant autoloader., (*3)

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

//Add any ini resources
$config->addResource('config.ini');
//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.
$config->load();

//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
</Files>
````

By example consider this ini files:

Global.ini:
```ini
[Section_A]
param1 = GlobalA1
param2 = GlobalA2

Local.ini:, (*4)

[Section_A]
param1 = LocalA1
param3 = LocalA3

[Section_B]
param1 = LocalB1
param2 = LocalB2

With this code: ```php //Create a new PhpConfig $config = new \PhpConfig\PhpConfig();, (*5)

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

$config->load(); $myConfiguration = $config->getConfig();, (*7)

print_r($myConfiguration); /* you get this array:, (*8)

Array( [Section_A]=>array( [param1] => LocalA1, [param2]=> globalA2, [param3]=> LocalA3 ), [Section_B]=>array( [param1] => LocalB1, [param2]=> LocalA2 ) ) */ ````, (*9)

License

The phpConfig is released under the MIT public license, (*10)

The Versions

10/10 2013

dev-master

9999999-dev https://github.com/sigjlr/phpConfig

Load INI configuration files

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

configuration ini

25/09 2013

0.1.0

0.1.0.0 https://github.com/sigjlr/phpConfig

Load INI configuration files

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

configuration ini