shazam / easy-config
读取Yaml配置文件
这个包的官方仓库似乎已经消失,因此该包已被冻结。
0.3.1
2016-08-18 13:07 UTC
Requires
- php: >=5.3
- symfony/yaml: 2.4.*
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2022-03-28 21:07:25 UTC
README
一个简单的PHP库,用于从Yaml文件中读取。
用法
将以下代码放置在类的构造函数或超类中
use EasyConfig\Config; $config = Config::getInstance(); $config->setUseCache(false); //Default is true, so no need to specify if you want to use APC $config->loadConfig( array( __DIR__ . '/../config/environment.yml', __DIR__ . '/../config/properties.yml' ) );
在代码的其他地方,你可以通过调用 $config->fetch() 和值的标题来加载配置值
$config = Config::getInstance();
$var = $config->fetch('heading', 'subheading'); //Fetches value under [heading][subheading]
$var = $config->fetch('heading', 'subheading', 'subheading'); //Fetches value under [heading][subheading][subheading]
$var = $config->fetch(); //Fetches the whole config
在获取配置值时,你可以指定任意多的键。