gfonseca / tunny
用于解析配置文件的模块
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: 2024-09-25 03:55:00 UTC
README
简单的配置文件解析
安装
$ composer require gfonseca/tunny
示例
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);
输出
Array ( [system] => Array ( [os] => Fedora [hd] => 1000000GB [memory] => 99999999 [cpu] => Intel [environment] => Array ( [iface2] => Gnome ) ) [network] => Array ( [modem] => U.S. Robotics ) )
定义默认值
class SampleDefaults extends \Tunny\Config { protected function defaults(){ return array( "System" => "Ubuntu" ); } }