PHPackages                             lmz/hyperf-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lmz/hyperf-config

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lmz/hyperf-config
=================

An independent component that provides configuration container.

v2.2.1(4y ago)046912MITPHPPHP &gt;=7.3

Since Jun 19Pushed 4y agoCompare

[ Source](https://github.com/liumingzhij26/config)[ Packagist](https://packagist.org/packages/lmz/hyperf-config)[ Docs](https://hyperf.io)[ RSS](/packages/lmz-hyperf-config/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (5)Dependencies (4)Versions (19)Used By (2)

hyperf-config
=============

[](#hyperf-config)

`composer require lmz/hyperf-config`

主要的目前是为了加载 `config/autoload` 带文件夹的配置，官方提供的配置文件只读取`.php`配置文件，如果有同名的文件就会被覆盖。

使用方法：
-----

[](#使用方法)

在`config/autoload/dependencies.php`添加，其他用法与官方一样

```
\Hyperf\Contract\ConfigInterface::class => \Hyperf\TfConfig\ConfigFactory::class,
```

demo
----

[](#demo)

`config/autoload/demo/test.php` 配置文件

```
return [
    'config' => [
        'db' => 'test',
    ],
];
```

官方结果：

```
'test' => [
    'config' => [
        'db' => 'test',
    ],
];
```

本项目结果：

```
[
    'demo' => [
        'test' => [
            'config' => [
                'db' => 'test',
            ],
        ],
    ],
]
```

使用环境变量
------

[](#使用环境变量)

根目录下有`.env`文件

```
PHASE=dev
```

`PHASE` 可以自定义如`dev` `publish` `production` `rd` 等

如 `PHASE=dev` ，`config/autoload` 下面有一个 `database.php` ，可以新建 `config/autoload/` 新建`dev/database.php`文件夹，系统会优先读取 `config/autoload/dev/database.php` 配置。

项目目的
----

[](#项目目的)

### 1、为什么不使用`.env`解决问题

[](#1为什么不使用env解决问题)

就拿数据库配置来说，目前我们有`5个数据库集群`，使用`.env`管理，就只能写成`env('DB_HOST_1', '127.0.0.1')` `env('DB_HOST_2', '127.0.0.1')`等，都写在`.env`里面会非常多配置

### 2、为什么不使用配置系统

[](#2为什么不使用配置系统)

新项目目前没有`Apollo` `阿里云 ACM 应用配置管理`，开发环境调试比较麻烦

注意事项
----

[](#注意事项)

1. 应该在 `.gitignore` 里面加上 `config/autoload/dev/*` 目录，不允许提交到代码库上面
2. 不允许子文件夹名与`PHASE`值同名，不会生效，如`config/autoload/demo/dev/test.php`，`dev` 文件夹不会被读取

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~95 days

Total

15

Last Release

1667d ago

Major Versions

v1.2.1 → v2.0.12020-10-09

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v2.2.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0dabbb6e648e15b1a36128bf06e81d1cc928c28c226707d8b11540c1b8b05a75?d=identicon)[liumingzhij26](/maintainers/liumingzhij26)

---

Top Contributors

[![huangzhhui](https://avatars.githubusercontent.com/u/12077148?v=4)](https://github.com/huangzhhui "huangzhhui (36 commits)")[![limingxinleo](https://avatars.githubusercontent.com/u/16648551?v=4)](https://github.com/limingxinleo "limingxinleo (31 commits)")[![msai2019](https://avatars.githubusercontent.com/u/166233036?v=4)](https://github.com/msai2019 "msai2019 (12 commits)")[![daydaygo](https://avatars.githubusercontent.com/u/3986303?v=4)](https://github.com/daydaygo "daydaygo (3 commits)")[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (2 commits)")[![wenbinye](https://avatars.githubusercontent.com/u/1221975?v=4)](https://github.com/wenbinye "wenbinye (1 commits)")[![gankbat](https://avatars.githubusercontent.com/u/22650353?v=4)](https://github.com/gankbat "gankbat (1 commits)")[![breath-co2](https://avatars.githubusercontent.com/u/1320528?v=4)](https://github.com/breath-co2 "breath-co2 (1 commits)")

---

Tags

phpconfigurationconfigswoolehyperf

### Embed Badge

![Health badge](/badges/lmz-hyperf-config/health.svg)

```
[![Health](https://phpackages.com/badges/lmz-hyperf-config/health.svg)](https://phpackages.com/packages/lmz-hyperf-config)
```

###  Alternatives

[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)[hyperf/swoole-tracker

A swoole tracker library for Hyperf.

1720.3k](/packages/hyperf-swoole-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
