承接 iampersistent/config-value-component 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-14