tunny

A php lib for parse config files

View on GitHub

Tunny

T u n n y

tunny:master

A simple configuration file parse

Instalation:

$ composer require gfonseca/tunny

Example:

system_php_array.php

<?php

return array(
	"system" => array(
		"os" => "Ubuntu",
		"hd" => "1000000GB"
	)
);

system_json.json

{
"system": {
	"os": "Fedora",
	"memory": 899789
	}
}

network_ini_file.ini

[system]
cpu = Intel
[network]
modem=U.S. Robotics

system_yaml.yml

system:
    memory: 99999999
    environment:
        iface2: Gnome

sample.php

<?php

require __DIR__."/../vendor/autoload.php";

$tunny = \Tunny\Config::make([
    "./system_php_array.php",
    "./network_json.json",
    "./system_ini_file.ini",
    "./system_yaml.yml"
]);


$conf = $tunny->get();
print_r($conf);

output

Array
(
    [system] => Array
        (
            [os] => Fedora
            [hd] => 1000000GB
            [memory] => 99999999
            [cpu] => Intel
            [environment] => Array
                (
                    [iface2] => Gnome
                )

        )

    [network] => Array
        (
            [modem] => U.S. Robotics
        )

)

Defining default values

class SampleDefaults extends \Tunny\Config
{
    protected function defaults(){
        return array(
            "System" => "Ubuntu"
        );
    }
}