usox / hacore
以严格模式读取 json 配置
v1.3.0
2019-02-15 07:21 UTC
Requires
- hhvm: ^4.0
- hhvm/hsl: ^4.0
Requires (Dev)
- facebook/fbexpect: ^2
- hhvm/hacktest: ^1.4
- hhvm/hhast: ^4.0
This package is auto-updated.
Last update: 2024-09-15 19:24:56 UTC
README
Hacore - Hack 配置读取器
Hacore 提供了一种简单的方法来以 Hack 严格模式读取格式为 json 的配置文件。
示例配置
Hacore 将所有配置值视为字符串并会显式转换。要访问单个键的值,只需使用 getLeaf($key_name)
。要获取完整的选项分支,使用 getBranch($key_name)
。
{ "foo":"bar", "barfoo":666, "more":{ "config":"options" } }
$reader = new \Usox\Hacore\Reader(); $reader->load('path-to-config.json') $reader->getLeaf('foo'); // returns 'bar' $reader->getLeaf('barfoo'); // returns '666' $reader->getBranch('more'); // returns a new Reader instance