|
Zhamao Framework
3.0.0-beta1
A high-performance chatbot + web framework
|
Public 成员函数 | |
| __construct (array $config_paths=[], string $environment='uninitiated') | |
| loadFiles () | |
| merge (string $key, array $config) | |
| get (string $key, mixed $default=null) | |
| set (array|string $key, mixed $value=null) | |
| addConfigPath (string $path) | |
| getEnvironment () | |
| setEnvironment (string $environment) | |
| reload () | |
| getHolder () | |
| getTrace (string $key) | |
成员变量 | |
| const | ALLOWED_FILE_EXTENSIONS = ['php', 'yaml', 'yml', 'json', 'toml'] |
| const | LOAD_ORDER = ['default', 'environment', 'patch'] |
| const | DEFAULT_CONFIG_PATH = SOURCE_ROOT_DIR . '/config' |
静态 Public 属性 | |
| static array | $environment_alias |
| __construct | ( | array | $config_paths = [], |
| string | $environment = 'uninitiated' |
||
| ) |
构造配置实例
| array | $config_paths | 配置文件路径 |
| string | $environment | 环境 |
| ConfigException | 配置文件加载出错 |
| addConfigPath | ( | string | $path | ) |
添加配置文件路径
| string | $path | 路径 |
| get | ( | string | $key, |
| mixed | $default = null |
||
| ) |
获取配置项
| string | $key | 配置项名称,可使用.访问数组 |
| mixed | $default | 默认值 |
| getEnvironment | ( | ) |
获取当前环境
| getHolder | ( | ) |
获取内部配置容器
| getTrace | ( | string | $key | ) |
获取配置项的来源
| string | $key | 配置项 |
| loadFiles | ( | ) |
加载配置文件
| ConfigException |
| merge | ( | string | $key, |
| array | $config | ||
| ) |
合并传入的配置数组至指定的配置项
请注意内部实现是 array_replace_recursive,而不是 array_merge
| string | $key | 目标配置项,必须为数组 |
| array | $config | 要合并的配置数组 |
| reload | ( | ) |
重载配置文件 运行期间新增的配置文件不会被加载哟~
| ConfigException |
| set | ( | array|string | $key, |
| mixed | $value = null |
||
| ) |
设置配置项 仅在本次运行期间生效,不会保存到配置文件中哦
如果传入的是数组,则会将键名作为配置项名称,并将值作为配置项的值 顺带一提,数组支持批量设置
| array | string | $key | 配置项名称,可使用.访问数组 |
| mixed | $value | 要写入的值,传入 null 会进行删除 |
| setEnvironment | ( | string | $environment | ) |
设置当前环境
变更环境后,将会自动调用 reload 方法重载配置
| string | $environment | 目标环境 |
|
static |
| const ALLOWED_FILE_EXTENSIONS = ['php', 'yaml', 'yml', 'json', 'toml'] |
| const DEFAULT_CONFIG_PATH = SOURCE_ROOT_DIR . '/config' |
| const LOAD_ORDER = ['default', 'environment', 'patch'] |