iampersistent/config-value-component
最新稳定版本:v1.3.0
Composer 安装命令:
composer require iampersistent/config-value-component
包简介
README 文档
README
Pull config from .env values or from Laminas config
Install
composer require iampersistent/config-value-component
Usage
$config = (new GatherConfigValues)($container, 'print');
In the .env file, the first part of the environment name must match the config name (case-insensitive). Each subsequent underscore creates a key in an array of the value.
PRINT_PRINTER=Epson TX-80
would result in
$printConfig = [ 'printer' => 'Epson TX-80', ];
If there is a default key, the case of that key will be used.
// print.config.php return [ 'print' => [ 'printerType' => null, ] ];
.env
PRINT_PRINTER=Epson TX-80
PRINT_PRINTERTYPE=dot-matrix
would result in
$printConfig = [ 'print' => [ 'printer' => 'Epson TX-80', 'printerType' => 'dot-matrix', ] ];
If there are conflicting values between the config files and the .env file, the .env value will be used
// print.config.php return [ 'print' => [ 'printerType' => null, 'speed' => 'fast', ] ];
.env
PRINT_PRINTER=Epson TX-80
PRINT_PRINTERTYPE=dot-matrix
PRINT_SPEED=slow
would result in
$printConfig = [ 'print' => [ 'printer' => 'Epson TX-80', 'printerType' => 'dot-matrix', 'speed' => 'slow', ] ];
Any values in the config that don't have a value in the .env remains as is
// print.config.php return [ 'print' => [ 'location' => 'Room 1', 'printerType' => null, 'speed' => 'fast', ] ];
.env
PRINT_PRINTER=Epson TX-80
PRINT_PRINTERTYPE=dot-matrix
PRINT_SPEED=slow
would result in
$printConfig = [ 'print' => [ 'location' => 'Room 1', 'printer' => 'Epson TX-80', 'printerType' => 'dot-matrix', 'speed' => 'slow', ] ];
统计信息
- 总下载量: 1.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-14