gfonseca / tunny
A module for parse configuration files
v1.4.2
2017-09-04 12:45 UTC
Requires
- php: >= 5.4
- symfony/yaml: ~3.0
Requires (Dev)
This package is not auto-updated.
Last update: 2025-03-26 06:04:11 UTC
README
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" ); } }