acgrid/config 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

acgrid/config

Composer 安装命令:

composer require acgrid/config

包简介

Configuration manager with deferred default value, transformation and caching.

README 文档

README

Features

  • Collection for configuration items
  • Deferred item definition, item is never defined until it is used
  • Self-descriptive, with IDE auto-completion powered
  • Deferred resolution of current and default value
  • Enumeration and export for administrative script and manager
  • Full control for populating pre-loaded data
  • Caching via PHP's ultra-fast APCu with write-back on demand
  • Shipped with some helpers for quick reader and writer

Usage

Definition

Extend Collection with each definition a public function

An Live Template of PHPStorm like this can be added to make a shortcut

public function $CONF_NAME$(): Item
{
    return $this->make(__FUNCTION__, $DEF_VALUE$, $READER$, $WRITER$);
}

Source

Instantiate your own Loader with a callback that return the array of raw data of configuration. The key shall be the Collection's FQN. Just require the dumped file in case of using a saved php configuration file. Call setApcu('key_prefix') to enable APCu caching.

Routines

Instantiate needed children instance of Collection, which a DI container is suggested to fulfil the task. Pass the loader in previous step. Then you call get the configuration by $collection->item()(). Note that __invoke() is used. Otherwise what you get is a Item object having many useful methods like def() and raw().

See tests for more detailed usage.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固