masnathan / config4all
此包已被弃用且不再维护。未建议替代包。
此类帮助您加载应用程序配置,支持php、xml、ini和json文件。
2.2.0
2016-10-04 09:48 UTC
Requires
- php: >=5.3.0
- masnathan/parser: dev-master
Requires (Dev)
- nette/neon: ^2.3
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
- symfony/var-dumper: ^2.7
- symfony/yaml: ^2.7
Suggests
- nette/neon: For working with NEON files.
- symfony/yaml: For working with YAML files.
This package is not auto-updated.
Last update: 2020-08-21 19:04:30 UTC
README
此类帮助您加载应用程序配置,支持php、xml、ini、yml、neon和json文件。
使用简单,您可以一次性加载多种格式的多个文件
安装
通过Composer
$ composer require masnathan/config4all
使用
use MASNathan\Config\Config; $config = new Config(); //You can load as many files as you want, one by one $config->load('configs/config.php', 'configs/database.php'); //or all the files with a certain extension at the same time $config->load('configs/*.json'); //you can even load multiple format files at the same time $config->load('configs/*.json', 'configs/*.yml'); //or can also load multiple files, regardless of the extension $config->load('configs/*.*'); //This is how you clear all the configurations $config->clear();
##获取信息
//To get a value, you just need to know the path to get there //if you want to know my name, just use the get method and pass the configuration file name //and the keys to get my name, like this echo $config->get('config', 'me', 'name'); //here are some other examples echo $config->get('config', 'github'); echo $config->get('database', 'host'); //if the value that you are trying to get doesn't exist, you'll get a null //you can also get the entire structure by calling the method get with no arguments var_dump($config->get());
##设置自己的配置
//You can also set new configs on the fly, or change existing ones $config ->set('a', 'b', 'c', 'value') ->set('config', 'me', 'name', 'Not Andre Filipe') ->set('database', 'host', 'first', 'localhost') ->set('database', 'host', 'second', 'somehost') ->set('this is a null field'); //This will return 'value' echo $config->set('a', 'b', 'c');
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
测试
$ composer test
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件andre.r.flip@gmail.com联系,而不是使用问题跟踪器。
致谢
许可
MIT许可证(MIT)。有关更多信息,请参阅许可文件。