eve-in-ua/multiconf
Composer 安装命令:
composer require eve-in-ua/multiconf
包简介
Library for global configuration.
关键字:
README 文档
README
Composer
composer require eve-in-ua/multiconf
OR
{
"require": {
"eve-in-ua/multiconf": "^v1.0.0"
}
}
Test
composer test
Examples
Env
{ENV_ROOT}/.env
ENV=DEV DB_HOST=localhost DB_USER=user_name DB_PASS=password DB_NAME=database_name
{ENV_ROOT}/.env.default
ENV=PROD DB_HOST= DB_PORT=3306 DB_USER= DB_PASS= DB_NAME= TABLE_PREFIX=
Config
{CONFIG_ROOT}/config/example.php
<?php return [ 'foo' => 'bar', 'zoo' => [ 'baz', // 0 => 'baz' ], ];
{CONFIG_ROOT}/config/example.default.php
<?php return [ 'foo' => 'baz', 'def' => 'def', ];
example.php will recursively override values from example.default.php config - so in example.php you can specify
only those configs which you want to override.
{CONFIG_ROOT}/config/a-first-config.php
<?php $multiConf = new \EveInUa\MultiConf\Config(); // version 1 $multiConf = new \MultiConf(); // version 2 $multiConf = \MultiConf::instance(); // version 3 - best // Wait for `example2` to load: if ($multiConf->waitFor('a-first-config', ['env', 'example2'])) { return null; } return [ 'foo' => 'baz', 'def' => 'def', 'example2-data' => $multiConf->config('example2'), ];
Usage
<?php // You can set directories manually for library using $_SERVER['DOCUMENT_ROOT'] as CONFIG_ROOT and ENV_ROOT define('CONFIG_ROOT', __DIR__); // optional, will use DOCUMENT_ROOT instead define('ENV_ROOT', __DIR__); // optional, will use DOCUMENT_ROOT instead require_once __DIR__ . '/vendor/autoload.php'; $multiConf = \MultiConf::instance(); $result = [ $multiConf->env(), // DEV - from ENV_ROOT/.env $multiConf->env('DB_HOST'), // localhost - from ENV_ROOT/.env $multiConf->env('DB_PORT'), // 3306 - from ENV_ROOT/.env.default $multiConf->config('example.foo'), // bar - from CONFIG_ROOT/config/example.php $multiConf->config('example.def'), // def - from CONFIG_ROOT/config/example.default.php ]; var_dump($result);
Output:
array(5) {
[0]=> string(3) "DEV"
[1]=> string(9) "localhost"
[2]=> int(3306)
[3]=> string(3) "bar"
[4]=> string(3) "def"
}
eve-in-ua/multiconf 适用场景与选型建议
eve-in-ua/multiconf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「config」 「eve-in-ua」 「multiconf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eve-in-ua/multiconf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eve-in-ua/multiconf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eve-in-ua/multiconf 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module to quickly and easily set PHP settings.
Server environment detection based on config array-file
Single and multi-dimensional parameter bag with dot-path access for PHP.
Laravel provider to be able to rewrite configuration
Advanced configuration manager for PHP with dotted-path access, file/directory/class loaders and a static facade.
Config component from JiNexus Framework
统计信息
- 总下载量: 1.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-15