PHPackages                             steady-as-hill/sooh-ini - 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. steady-as-hill/sooh-ini

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

steady-as-hill/sooh-ini
=======================

ini manage

1.2(7y ago)0251MITPHP

Since Jun 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/waynewn/sooh-ini)[ Packagist](https://packagist.org/packages/steady-as-hill/sooh-ini)[ RSS](/packages/steady-as-hill-sooh-ini/feed)WikiDiscussions master Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (1)

配置管理类
=====

[](#配置管理类)

配置分情况统一管理的封装类。设计目的是解决两点：

1. 简化和统一获取配置的方式（比如获取时如果尚未加载就自动加载配置）
2. 支持多种配置格式，php的,ini的，单一大文件或拆开的多个小文件

配置一般是多级的，比如数据库配置

```
    {
        DB: {
            mysqlAtServer1:{
                server: "1.2.3.4",
                user: "root"
                pass: "123456"
            }
        },
        Session: {
            ....
        }
    }

```

这种情况下，可以通过 ini::getInstance()-&gt;getIni('DB.mysqlAtServer1.server')得到"1.2.3.4"

也可以通过 ini::getInstance()-&gt;getIni('DB.mysqlAtServer1')得到 {server:"1.2.3.4",user:"root",pass:"123456"}

配置支持几种写法，参看：[Ini文件格式](Ini.md)

基本使用
----

[](#基本使用)

1） 初始化构建ini实例(以目录模式为例)：

`\Sooh\Ini::getInstance()->initLoader(new \Sooh\IniClasses\Files("/root/SingleService/_config"));`

如果是swoole这种，两个请求之间不会彻底释放的，需要在处理controller的action之前，ini-&gt;runtime-&gt;free();

2） 基本使用

```
    \Sooh\Ini::getInstance()->getIni("Email.server");
    \Sooh\Ini::getInstance()->getRuntime("some.runtime.var");
    \Sooh\Ini::getInstance()->setRuntime("some.runtime.var",mixed);

```

关于配置的说明
-------

[](#关于配置的说明)

配置按存储位置分为本地和远程；按类型基本可以分为模块配置和资源配置；按作用域可以分为静态配置、运行时的动态配置以及外部配置（可跨越进程的动态配置）

Ini提供了三个public的属性应对上述情况：

- statics 静态配置，这里主要存储系统初始化参数，一般不应该在运行时更改（并发覆盖啥的要自行考虑清除）
- runtime 运行时，主要是当前进程处理中用的，每个请求之初应该清空，当框架不会自动释放时(比如swoole里处理任务的函数之前生成的实例)，请在收到请求之初执行 ini-&gt;onNewRequest()
- permanent 永久的（比如redis），可跨进程间共享的，不是必须的，下一版本准备提供一个redis的

针对statics，分别提供了\\Sooh\\IniClasses\\Files 和 \\Sooh\\IniClasses\\Url 两个获取配置的驱动

permanent 一般是自行定制的

详细使用和限制
-------

[](#详细使用和限制)

**注意：由于在定位配置的时候使用了“.”，所以配置的键值部分不能有“.”!!!**

详细用法参看 [Ini设计和使用](docs/Design.md)

另外，当凑数也罢，这里增加了shutdown管理的相关方法，使用时要自行配套使用：

function registerShutdown($func,$identifier)

注册一个shutdown方法，当onShutdown的时候执行。（$identifier 是标识， 如果执行时抛出异常了，error\_log的时候会给出这个identifier）

public function onShutdown()

系统执行结束后的清理，需根据运行环境框架自行选择调用位置触发执行

您也可以使用自己的Ini类替换使用：

通过 \\Sooh\\Ini::getInstance(其他实例) 设置一下，之后 \\Sooh\\Ini::getInstance()获 得的就是这个新的“其他实例”了

配置节点的名字里如果有"."，那么只能获取到上一级，之后的节点会取不到。

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

3

Last Release

2876d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8f4ca102171f00a75538266b967af5dcf17882e2cc351312ae734d7db3d3888?d=identicon)[waynewn](/maintainers/waynewn)

---

Top Contributors

[![waynewn](https://avatars.githubusercontent.com/u/9529021?v=4)](https://github.com/waynewn "waynewn (2 commits)")

---

Tags

ini

### Embed Badge

![Health badge](/badges/steady-as-hill-sooh-ini/health.svg)

```
[![Health](https://phpackages.com/badges/steady-as-hill-sooh-ini/health.svg)](https://phpackages.com/packages/steady-as-hill-sooh-ini)
```

###  Alternatives

[jbzoo/data

An extended version of the ArrayObject object for working with system settings or just for working with data arrays

891.6M23](/packages/jbzoo-data)

PHPackages © 2026

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