elgentos/parser
最新稳定版本:3.0.0
Composer 安装命令:
composer require elgentos/parser
包简介
Elgentos Parser for json/yaml files to readable array
README 文档
README
Parse content from json/yaml/csv/text to a usable array
Description
Use this library to turn your day-to-day configurations into usable arrays/objects.
Supports json, yaml, csv, xml and plain text.
<?php /** * Read a file, import recursive and return a merged array */ $data = Elgentos\Parser::readFile('file.json');
<?php /** * Read a file, no recursion */ $data = Elgentos\Parser::readSimple('file.json');
Instalation
To use in your project require
composer require elgentos/parser
To support YAML also require:
composer require symfony/yaml
Directives
You can use directives inside your file.
@import
Load content of other files directly in your current file.
YAML
othercontent: "@import": path/to/other/file.yaml
JSON
{
"othercontent": {"@import": "path/to/otherfile.yaml" }
}
CSV
"@import"
"path/to/file.json"
"path/to/otherfile.yaml"
"path/to/file2.yaml"
@import-dir
Read a directory recursively.
base: "@import-dir": "path/to/directory"
{
"base": {"@import-dir": "path/to/directory"}
}
Customization
Due Service Contracts you can easily add your own functionality:
- Rules
\Elgenttos\Parser\Interfaces\RuleInterface - Matcher
\Elgenttos\Parser\Interfaces\MatcherInterface - Parser
\Elgenttos\Parser\Interfaces\RuleInterface - Stories
\Elgenttos\Parser\Interfaces\StoriesInterface
Automated creation of objects
Technical description
For our technical docs docs/technical.md.
统计信息
- 总下载量: 34.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-18