-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: update the release action script, and update readme
- Loading branch information
Showing
4 changed files
with
182 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
options: | ||
title: '## Change Log' | ||
style: gh-release | ||
title: '## Change Log' | ||
# style allow: simple, markdown(mkdown), ghr(gh-release) | ||
style: gh-release | ||
# group names | ||
names: [Refactor, Fixed, Feature, Update, Other] | ||
#repo_url: https://github.com/gookit/gcli | ||
|
||
filters: | ||
# message length >= 12 | ||
- name: msgLen | ||
minLen: 12 | ||
# message words >= 3 | ||
- name: wordsLen | ||
minLen: 3 | ||
# message length should >= 12 | ||
- name: msg_len | ||
min_len: 12 | ||
# message words should >= 3 | ||
- name: words_len | ||
min_len: 3 | ||
- name: keyword | ||
keyword: format code | ||
exclude: true | ||
- name: keywords | ||
keywords: ['format code'] | ||
keywords: format code, action test | ||
exclude: true | ||
|
||
# group match rules | ||
# not matched will use 'Other' group. | ||
groups: | ||
- name: New | ||
keywords: [add, new] | ||
rules: | ||
- name: Refactor | ||
start_withs: [refactor, break] | ||
contains: ['refactor:', 'break:'] | ||
- name: Fixed | ||
startWiths: [add, new] | ||
keywords: [add, new] | ||
- name: Feat | ||
startWiths: [feat] | ||
keywords: [feature] | ||
start_withs: [fix] | ||
contains: ['fix:'] | ||
- name: Feature | ||
start_withs: [feat, new] | ||
contains: ['feat:', 'new:'] | ||
- name: Update | ||
startWiths: [update, 'up:'] | ||
keywords: [update] | ||
start_withs: [up] | ||
contains: ['update:', 'up:'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Config | ||
|
||
[![License](https://img.shields.io/packagist/l/phppkg/config.svg?style=flat-square)](LICENSE) | ||
[![Php Version](https://img.shields.io/badge/php-%3E=8.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/phppkg/config) | ||
[![Latest Stable Version](http://img.shields.io/packagist/v/phppkg/config.svg)](https://packagist.org/packages/phppkg/config) | ||
[![Actions Status](https://github.com/phppkg/easytpl/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/easytpl/actions) | ||
|
||
PHP的配置数据加载,管理,获取,支持多种数据格式. | ||
|
||
- 配置数据加载,管理,获取 | ||
- 支持加载多个配置数据,会自动合并 | ||
- 支持 INI,JSON,YAML,TOML,NEON,PHP 等格式的文件内容 | ||
- 支持导出整个配置数据到文件 | ||
- 简单的多语言配置数据管理 | ||
|
||
> **[EN README](README.md)** | ||
## 安装 | ||
|
||
**composer** | ||
|
||
- Required PHP 8.0+ | ||
|
||
```bash | ||
composer require phppkg/config | ||
``` | ||
|
||
## 快速开始 | ||
|
||
先创建一个配置实例,就可以加载指定的配置数据了. | ||
|
||
```php | ||
use PhpPkg\Config\ConfigBox; | ||
|
||
$config = ConfigBox::new(); | ||
$config->loadFromFiles([ | ||
__DIR__ . '/test/testdata/config.ini', | ||
__DIR__ . '/test/testdata/config.neon', | ||
__DIR__ . '/test/testdata/config.yml', | ||
__DIR__ . '/test/testdata/config.toml', | ||
]); | ||
``` | ||
|
||
### 查看加载的数据 | ||
|
||
```php | ||
// dump config | ||
vdump($config->getData()); | ||
``` | ||
|
||
**Output**: | ||
|
||
```php | ||
CALL ON PhpPkg\ConfigTest\ConfigBoxTest(24): | ||
array(7) { | ||
["name"]=> string(6) "inhere" | ||
["age"]=> int(89) | ||
["atIni"]=> string(6) "value0" | ||
["arr0"]=> array(3) { | ||
[0]=> string(2) "ab" | ||
[1]=> int(23) | ||
[2]=> string(2) "de" | ||
} | ||
["map0"]=> array(2) { | ||
["key0"]=> string(4) "val0" | ||
["key1"]=> string(4) "val1" | ||
} | ||
["atNeon"]=> string(6) "value1" | ||
["atYaml"]=> string(6) "value2" | ||
["atToml"]=> string(6) "val at toml" | ||
} | ||
``` | ||
|
||
## 获取值 | ||
|
||
可以获取指定类型的返回值,同时支持链式key方式获取值 | ||
|
||
```php | ||
/** @var PhpPkg\Config\ConfigBox $config */ | ||
$config->getInt('age'); // int(89) | ||
$config->getString('name'); // string('inhere') | ||
$config->get('arr0'); | ||
$config->get('map0'); | ||
|
||
// get value by key-path. | ||
$config->getInt('arr0.1'); // int(23) | ||
$config->getString('map0.key0'); // string('val0') | ||
``` | ||
|
||
## 设置值 | ||
|
||
```php | ||
/** @var PhpPkg\Config\ConfigBox $config */ | ||
$config->set('name', 'INHERE'); | ||
$config->set('map0.key0', 'new value'); | ||
``` | ||
|
||
## 导出到文件 | ||
|
||
支持导出整个配置数据到文件. | ||
|
||
```php | ||
use PhpPkg\Config\ConfigBox; | ||
|
||
/** @var ConfigBox $config */ | ||
$config->exportTo('/path/to/file.json'); | ||
$config->exportTo('/path/to/my.conf', ConfigBox::FORMAT_YAML); | ||
``` | ||
|
||
## More load methods | ||
|
||
- `loadFromFiles(array $filePaths, string $format = '')` | ||
- `loadFromStrings(string $format, string ...$strings)` | ||
- `loadFromSteam(string $format, resource $stream)` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |