hurtcode / configure
创建配置的库
1.0.1
2021-06-22 17:14 UTC
Requires
- php: 8.*
- psr/cache: ^2
This package is auto-updated.
Last update: 2024-09-29 06:08:40 UTC
README
这是一个为各种系统创建配置的库。它提供了一个基本接口和一个工作单元。配置是一组静态、预定义的参数
开始工作
// first: create configurator unit of work $configurator = new Configurator( ConfigInterface::class, // your config realization CompilerInterface::class, // your compiler realization CacheItemPoolInterface::class // your cache realization ); $configs = $configurator->run(); // start configuration building
配置器
这是一个执行创建配置所有工作的单元。它依赖于两个接口:ConfigInterface
和 CompilerInterface
。配置器只编译配置一次,然后从缓存中获取。
ConfigInterface
此接口负责定位配置目录和输入配置文件。其主要目的是展示编译器需要从哪里和什么位置获取信息
CompilerInterface
此接口负责编译配置。它接受主要配置文件的字符串内容并将其解析为键值对数组。这种事物顺序允许您使用任何格式作为配置文件(json、yaml、xml等)。
建议工作流程
- ConfigInterface提供文件内容字符串
- CompilerInterface使用特定规则解析它
- 配置器对所有规则进行整理并缓存结果。