Skip to content

Commit 9261b49

Browse files
committed
update something. update readme
1 parent abee6dd commit 9261b49

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
# file-parse for php
1+
# 文件内容解析
22

3-
parse ini,json,yml file.
3+
`ini`, `json`, `yml` 格式的文件解析
4+
5+
- json 文件支持去除注释,即是有注释不会导致解析失败
6+
- 支持特殊关键字
7+
- `extend` 继承另一个文件的内容
8+
- `import` 导入另一个文件的内容
9+
- `reference` 参考另一个key的值 **todo**
10+
11+
例如在 yml 文件(其他格式的文件类似)可以这样:
12+
13+
```text
14+
// will parse special keywords
15+
extend: ../parent.yml
16+
debug: true
17+
db: import#../db.yml
18+
cache:
19+
debug: reference#debug
20+
```
421

522
## install
623

src/IniParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected static function doParse($string, $enhancement = false, callable $pathH
3535
}
3636

3737
/** @var array $array */
38-
$array = parse_ini_string(trim($string), true);
38+
$array = \parse_ini_string(trim($string), true);
3939

4040
/*
4141
* Parse special keywords
@@ -60,7 +60,7 @@ protected static function doParse($string, $enhancement = false, callable $pathH
6060
// $importFile is file
6161
if (\is_file($extendFile)) {
6262
$data = \file_get_contents($extendFile);
63-
$array = \array_merge(parse_ini_string(trim($data), true), $array);
63+
$array = \array_merge(\parse_ini_string(trim($data), true), $array);
6464
} else {
6565
throw new \UnexpectedValueException("needed extended file [$extendFile] don't exists!");
6666
}

src/JsonParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class JsonParser extends BaseParser
1818
{
1919
/**
20-
* parse INI
20+
* parse JSON
2121
* @param string $string Waiting for the parse data
2222
* @param bool $enhancement 启用增强功能,支持通过关键字 继承、导入、参考
2323
* @param callable $pathHandler When the second param is true, this param is valid.
@@ -42,8 +42,8 @@ protected static function doParse($string, $enhancement = false, callable $pathH
4242
/*
4343
* Parse special keywords
4444
*
45-
* extend = ../parent.yml
46-
* db = import#../db.yml
45+
* extend = ../parent.json
46+
* db = import#../db.json
4747
* [cache]
4848
* debug = reference#debug
4949
*/

0 commit comments

Comments
 (0)