vmassalov/config
最新稳定版本:v1.0.0-alpha
Composer 安装命令:
composer require vmassalov/config
包简介
Configuration service
README 文档
README
Library for matching rulesets based on file configs
The main goal of this package is to move out endless sequences of business logic 'elseif' outside of the code. It can be mapping exception classes to error codes, discount calculation rules, or any other strategy conditions. All conditions that do not change often enough and are not worth putting in the database can be conveniently transferred to the configs.
Install
Via composer
composer require vmassalov/config
Quick usage
Create yaml config file, e.g.:
- conditions: dayOfWeek: - monday - tuesday - wednesday - thursday - friday projectPriority: - normal - minor result: salaryRate: 1 needOvertimeApprove: true - conditions: dayOfWeek: - monday - tuesday - wednesday - thursday - friday projectPriority: critical result: salaryRate: 1 needOvertimeApprove: false - conditions: projectPriority: critical result: salaryRate: 2 needOvertimeApprove: false
All result blocks should contain same keys. All condition block can contain a different keys with single or multiple options.
$configClient = \VMassalov\Config\ClientFactory::build('filesystem://./path/to/configs'); $configClient->find( 'config.yaml', [ 'dayOfWeek' => 'sunday', 'projectPriority' => 'critical', ], );
Client will return a result of first full match item based on passed criteria
Configuration
DSN
filesystem://
Config syntax
See examples in tests/functional/stubs/yaml/baseConfig.yaml
Test
Run unit and functional test in docker
make build && make test
Run unit and functional test locally
php ./vendor/bin/phpunit
Roadmap
- Add JSON support
- Add XML support
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-22