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

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

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

userfrosting/config

最新稳定版本:4.5.0

Composer 安装命令:

composer require userfrosting/config

包简介

Configuration module for UserFrosting

README 文档

README

Latest Version Software License Join the chat at https://chat.userfrosting.com/channel/support Donate

Branch Build Coverage Style
master
develop  

Usage

Create a file default.php, in a directory /path/to/core/config/:

default.php

return [
    'contacts' => [
        'housekeeper' => [
            'name' => 'Alex',
            'email' => 'alex@cleansthetoilet.com'
        ]
    ]
];

Suppose now you have another config file which can override values in this base config file. For example, in /path/to/plugin/config/, you have:

default.php

return [
    'contacts' => [
        'housekeeper' => [
            'name' => 'Alex "the man" Weissman'
        ]
    ]
];

You can generate an ordered list of these configuration files using the ConfigPathBuilder class, and merge them together using an instance of UserFrosting\Support\Respository\Loader\ArrayFileLoader.

Path builder

Create ResourceLocator and ConfigPathBuilder classes to build a list of configuration files:

$locator = new ResourceLocator(__DIR__);
$locator->registerLocation('core', 'path/to/core');
$locator->registerLocation('plugin', 'path/to/plugin');
$locator->registerStream('config', '', 'config/');

$builder = new ConfigPathBuilder($locator, 'config://');
$paths = $builder->buildPaths();

// Generates a list of paths:
[
    '/core/config/default.php'
    '/plugin/config/default.php'
]

Data loader

You can then use the ArrayFileLoader class to load and merge all configuration data from this list of paths:

$loader = new \UserFrosting\Support\Respository\Loader\ArrayFileLoader($builder->buildPaths());
$config = new \UserFrosting\Support\Respository\Repository($loader->load());

Config files in multiple paths will be merged in the order in which the paths are specified. You can now access your configuration data via the standard Repository methods:

echo $config->get('contacts.housekeeper.name');
// Prints 'Alex'

You can also specify environment-specific config files in each path. If an environment name is passed to buildPaths(), ConfigPathBuilder will merge in the environment-specific file in a path immediately after merging in default.php:

development.php

return [
    'database' => [
        'password' => 'sup3rC-cr3t'
    ]
];

To merge this in, you would call:

$paths = $builder->buildPaths('development');

Style Guide

Testing

userfrosting/config 适用场景与选型建议

userfrosting/config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.86k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「configuration」 「config」 「userfrosting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 userfrosting/config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 userfrosting/config 我们能提供哪些服务?
定制开发 / 二次开发

基于 userfrosting/config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 7
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-29