PHPackages                             phppkg/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. phppkg/config

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

phppkg/config
=============

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

v1.1.6(1y ago)133.5k↓100%[1 issues](https://github.com/phppkg/config/issues)MITPHPPHP &gt;=8.1CI passing

Since Jan 30Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/phppkg/config)[ Packagist](https://packagist.org/packages/phppkg/config)[ Docs](https://github.com/phppkg/config)[ RSS](/packages/phppkg-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (14)Used By (0)

Config
======

[](#config)

[![License](https://camo.githubusercontent.com/10c6287c821e2167f201f40b9f84f50db6d664621e8f9d5eb812cbe43596b2b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870706b672f636f6e6669672e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Php Version](https://camo.githubusercontent.com/d1329d97bf13f645f002a9e6b31603eb7400f3ceb4a17d0a79ec66443cfd6f80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706870706b672f636f6e6669673f6d61784167653d32353932303030)](https://packagist.org/packages/phppkg/config)[![Latest Stable Version](https://camo.githubusercontent.com/0a547882b6401c25727a08c80b99c5cee448ba046536c1718252cafbe2c192ee/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870706b672f636f6e6669672e737667)](https://packagist.org/packages/phppkg/config)[![Actions Status](https://github.com/phppkg/config/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/config/actions)

🗂 Config load, management, merge, get, set and more.

- Config data load, management
- Support load multi config data, will auto merge
- Supports INI,JSON,YAML,TOML,NEON,PHP format file
- Support for exporting configuration data to file
- Language data management

> **[中文说明](README.zh-CN.md)**

Install
-------

[](#install)

**composer**

```
composer require phppkg/config
```

Usage
-----

[](#usage)

create and load config data. load multi file, will auto merge data.

```
use PhpPkg\Config\ConfigBox;

$config = ConfigBox::new();
$config->loadFromFiles([
    __DIR__ . '/test/testdata/config.ini',
    __DIR__ . '/test/testdata/config.neon',
    __DIR__ . '/test/testdata/config.yml',
    __DIR__ . '/test/testdata/config.toml',
]);
```

### Created in other ways

[](#created-in-other-ways)

```
use PhpPkg\Config\ConfigBox;

$config = ConfigBox::newFromFiles([
    // ... config file list
]);

$config->loadIniFile('path/to/my.ini')
```

### More load methods

[](#more-load-methods)

- `loadFromFiles(array $filePaths, string $format = '')`
- `loadFromStrings(string $format, string ...$strings)`
- `loadFromSteam(string $format, resource $stream)`
- `loadIniFile(string $filepath)`
- `loadJsonFile(string $filepath)`
- `loadJson5File(string $filepath)`
- `loadYamlFile(string $filepath)`
- `loadPhpFile(string $filepath)`

### Dump data

[](#dump-data)

```
// dump config
vdump($config->getData());
```

**Output**:

```
CALL ON PhpPkg\ConfigTest\ConfigBoxTest(24):
array(7) {
  ["name"]=> string(6) "inhere"
  ["age"]=> int(89)
  ["atIni"]=> string(6) "value0"
  ["arr0"]=> array(3) {
    [0]=> string(2) "ab"
    [1]=> int(23)
    [2]=> string(2) "de"
  }
  ["map0"]=> array(2) {
    ["key0"]=> string(4) "val0"
    ["key1"]=> string(4) "val1"
  }
  ["atNeon"]=> string(6) "value1"
  ["atYaml"]=> string(6) "value2"
  ["atToml"]=> string(6) "val at toml"
}
```

Get value
---------

[](#get-value)

```
/** @var PhpPkg\Config\ConfigBox $config */
$config->getInt('age'); // int(89)
$config->getString('name'); // string('inhere')
$config->get('arr0');
$config->get('map0');

// get value by key-path.
$config->getInt('arr0.1'); // int(23)
$config->getString('map0.key0'); // string('val0')
```

Set value
---------

[](#set-value)

```
/** @var PhpPkg\Config\ConfigBox $config */
$config->set('name', 'INHERE');
$config->set('map0.key0', 'new value');

// set multi at once
$config->sets([
    'key1' => 'value1',
    'key2' => 'value2',
    // ...
]);
```

Export to file
--------------

[](#export-to-file)

Export config data to file.

```
use PhpPkg\Config\ConfigBox;

/** @var ConfigBox $config */
$config->exportTo('/path/to/file.json');
$config->exportTo('/path/to/my.conf', ConfigBox::FORMAT_YAML);
```

PHPPkg Projects
---------------

[](#phppkg-projects)

- [phppkg/config](https://github.com/phppkg/config) - 🗂 Config load, management, merge, get, set and more.
- [phppkg/easytpl](https:://github.com/phppkg/easytpl) - ⚡️ Simple and fastly template engine for PHP
- [phppkg/http-client](https:://github.com/phppkg/http-client) - An easy-to-use HTTP client library for PHP
- [phppkg/ini](https:://github.com/phppkg/ini) - 💪 An enhanced `INI` format parser written in PHP.
- [phppkg/jenkins-client](https:://github.com/phppkg/jenkins-client) - Designed to interact with Jenkins CI using its API.
- [phppkg/phpgit](https:://github.com/phppkg/phpgit) - A Git wrapper library for PHP

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance63

Regular maintenance activity

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 82.9% 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 ~219 days

Recently: every ~268 days

Total

13

Last Release

384d ago

PHP version history (6 changes)v1.0.0PHP &gt;=7.0.0

v1.0.1PHP &gt;7.0.0

v1.0.3PHP &gt;7.1.0

v1.0.5PHP &gt;=8.0

v1.1.0PHP &gt;=8.0.1

v1.1.6PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![inhere](https://avatars.githubusercontent.com/u/5302062?v=4)](https://github.com/inhere "inhere (68 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")

---

Tags

configconfigsconfigurationconfiguration-managementjsonphpphp-configtomlphpjsonJSON5configlibraryyamlinitomlconfig-manageconfig-load

### Embed Badge

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

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

###  Alternatives

[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M169](/packages/hassankhan-config)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.2k1](/packages/m1-vars)[thewunder/conphigure

Framework Agnostic Configuration Library

3115.9k](/packages/thewunder-conphigure)[yosymfony/config-loader

Configuration file loader

10108.1k1](/packages/yosymfony-config-loader)

PHPackages © 2026

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