2017 © Pedro Peláez
 

library simplini

A simple INI reader. This project is heavly inspired to Zend_Config_Ini

image

wdalmut/simplini

A simple INI reader. This project is heavly inspired to Zend_Config_Ini

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Simple INI

A simple INI reader. This project is heavly inspired to Zend_Config_Ini, (*1)

Unit Testing Status

Build Status, (*2)

Sections

Simplini allow multiple sections and section (multiple sections) override(s)., (*3)

[prod]
a="ciao"
b=hello

[dev : prod]
a="ecco"

Force the dev state:, (*4)

<?php
$conf = new Config();
$conf->load(__DIR__ . '/my.ini', 'dev');

echo $conf->prod()->a; // will echo "ecco"

Arrays

Array support, (*5)

a[] = one
a[] = two
a[] = three
<?php
$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

var_dump(conf->a); // array(one,two,three)

Nested objects

Nested Objects, (*6)

[production]
a.b.c = "Hello"
<?php
$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

echo conf->production()->a->b-c; // will echo "hello"

Multiple sections

[mysql]
db.host = "localhost"
db.user = "user"
db.password = "password"

[redis]
nosql.a.host = "localhost"
nosql.b.host = "192.168.2.2"
<?php
$conf = new Config();
$conf->load(__DIR__ . '/my.ini');

echo $conf->mysql()->db->host; // localhost

echo $conf->redis()->nosql->b->host; // 192.168.2.2

Override strategies

You have three types of overrides., (*7)

[prod]
a = hello

[dev : prod]
a = ciao

[mysql]
host = localhost

[dm : mysql]
host = 192.168.2.2

[redis]
host = localhost

[rd : redis]
host = 192.168.3.3

Override all

<?php
$conf = new Config();
$conf->load(__DIR__ . '/a.ini', true);

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo 192.168.2.2
echo $conf->redis()->host; // echo 192.168.3.3

Override only one section

<?php
$conf = new Config();
$conf->load(__DIR__ . '/a.ini', 'dev');

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo localhost
echo $conf->redis()->host; // echo localhost

Override a group of sections

<?php
$conf = new Config();
$conf->load(__DIR__ . '/a.ini', array('dev', 'dm'));

echo $conf->prod()->a; // echo ciao
echo $conf->mysql()->host; // echo 192.168.2.2
echo $conf->redis()->host; // echo localhost

The Versions

24/03 2014

dev-master

9999999-dev

A simple INI reader. This project is heavly inspired to Zend_Config_Ini

  Sources   Download

MIT

24/03 2014

0.0.2

0.0.2.0

A simple INI reader. This project is heavly inspired to Zend_Config_Ini

  Sources   Download

MIT

24/03 2014

0.0.1

0.0.1.0

  Sources   Download