定制 geeklab/conf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

geeklab/conf

Composer 安装命令:

composer require geeklab/conf

包简介

Immutable configuration system for PHP >= 8.1

README 文档

README

License: BSD phpstan enabled Scrutinizer Code Quality Code Coverage

geeklab/conf

Immutable configuration system loader & parser for PHP >= 8.1 that supports multiple file formats and has some templating features. This library is an alternative to '.env' type configuration libraries and uses the Strategy Pattern.

Benchmarks

Latest

4.0.0 (2020-11-24): Updating to more >= 8.1.0 compatible.

Features:

  • Multi-file configuration loading, no more monolithic configurations!
  • Self referencing placeholders. @[X.Y.Z]
  • Recursive self referencing placeholders. @[@[X.Y.Z].SOME_KEY]
  • Environment variable placeholders. $[ENVIRONMENT_VARIABLE_NAME] (PHP likes ${YOUR_TEXT_HERE} a little too much...)
  • Can use INI, JSON, YAML and Array files.
  • Immutability, since you shouldn't change your configuration during run time.
  • Can inject values, to make things really dynamic.

Installation:

composer require geeklab/conf

Usage:

Basic:

// Where the configurations are.
$configurationDirectory = __DIR__ . '/config/';

// Load Configuration system with the JSON Configuration Driver 
$configuration = new GLConf(
    new JSONConfDriver(
        $configurationDirectory . 'system.json',  // Path and file name of main (top level) configuration.
        $configurationDirectory                   // Path to the other configuration files. 
    ),
    ['mySecretKey' => md5(rand())],                // Value injections.
    ['keys_to_lower']                              // Options:
                                                   //  Options to change the case of the key if returning a keyed array:    
                                                   //  keys_upper_case, keys_lower_case, keys_same_case
);

$configuration->init();

// Get the whole configuration.
var_export($configuration->getAll());

// Get one item.
var_export($configuration->get('space_pants.look_at_my'));

Detailed:

PSR Compliance:

  • PSR-1
  • PSR-2
  • PSR-4
  • PSR-12

Todo:

  • More Documentation.
  • Include .env?

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2018-11-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固