PHPackages                             phppkg/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. phppkg/ini

ActiveLibrary

phppkg/ini
==========

An enhanced PHP INI parser

v0.1.4(11mo ago)13.8k↓100%1MITPHPPHP &gt;8.1CI passing

Since Nov 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/phppkg/ini)[ Packagist](https://packagist.org/packages/phppkg/ini)[ Docs](https://github.com/phppkg/ini)[ RSS](/packages/phppkg-ini/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (1)Versions (6)Used By (1)

INI
===

[](#ini)

[![License](https://camo.githubusercontent.com/ab2fecf96eacad42aa4375f2ae8b98117031d1f0b59ca1ea512020af1ce030c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f706870706b672f696e693f7374796c653d666c61742d737175617265)](LICENSE)[![Php Version](https://camo.githubusercontent.com/11f2ef442ffe856e45487198a63e357efe960c63831b57771586e1cd86063178/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706870706b672f696e693f6d61784167653d32353932303030)](https://packagist.org/packages/phppkg/ini)[![GitHub tag (latest SemVer)](https://camo.githubusercontent.com/48b66b0f74905ce197e8b6ebebfad9c58adf080be8e1ff6a83113cec0b3a610b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f706870706b672f696e69)](https://github.com/phppkg/ini)[![Actions Status](https://github.com/phppkg/ini/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/ini/actions)

💪 An enhanced `INI` format parser written in PHP.

- auto convert data type, eg: `int, bool, float`
- support encode data to INI string.
- ignores commented lines that start with ";" or "#"
    - ignores broken lines that do not have "="
- supports array values and array value keys
- enhance: supports inline list array value
- enhance: supports multi line string. use `'''` or `"""`
- enhance: supports add interceptor before collect value
- TODO: support parse ENV var. `${SHELL | bash}`

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

Install
-------

[](#install)

**composer**

```
composer require phppkg/ini
```

Usage
-----

[](#usage)

example ini:

```
; comments line
// comments line
# comments line

int = 23
float = 34.5
str=ab cd
bool=true
empty-str =

# support multi-line
multi-line = '''
this is
  a multi
 line string
'''

# simple inline list array
inlineList = [ab, 23, 34.5]

# simple multi-line list array, equals the 'simpleList1'
simpleList[] = 567
simpleList[] = "some value"

# simple multi-line list array
[simpleList1]
- = 567
- = "some value"

# simple k-v map
[simpleMap]
val_one = 567
val_two = 'some value'

# multi level list array
[array]
arr_sub_key[] = "arr_elem_one"
arr_sub_key[] = "arr_elem_two"
arr_sub_key[] = "arr_elem_three"

# multi level k-v map sub array
[array_keys]
val_arr_two[6] = "key_6"
val_arr_two[some_key] = "some_key_value"
```

### Decode

[](#decode)

Decode from INI string.

```
use PhpPkg\Ini\Ini;
use Toolkit\Stdlib\Std\Collection;

$data = Ini::decode($ini);
vdump($data);

$cfg = Collection::new($data);
$int = $cfg->get('int'); // 23
```

**Output**:

```
array(13) {
  ["int"]=> int(23)
  ["float"]=> float(34.5)
  ["str"]=> string(5) "ab cd"
  ["bool"]=> bool(true)
  ["empty-str"]=> string(0) ""
  ["multi-line"]=> string(30) "this is
  a multi
 line string"
  ["inlineList"]=> array(3) {
    [0]=> string(2) "ab"
    [1]=> int(23)
    [2]=> float(34.5)
  }
  ["simpleList"]=> array(2) {
    [0]=> int(567)
    [1]=> string(10) "some value"
  }
  ["simpleList1"]=> array(2) {
    [0]=> int(567)
    [1]=> string(10) "some value"
  }
  ["simpleMap"]=> array(2) {
    ["val_one"]=> int(567)
    ["val_two"]=> string(10) "some value"
  }
  ["array"]=> array(1) {
    ["arr_sub_key"]=> array(3) {
      [0]=> string(12) "arr_elem_one"
      [1]=> string(12) "arr_elem_two"
      [2]=> string(14) "arr_elem_three"
    }
  }
  ["array_keys"]=> array(1) {
    ["val_arr_two"]=> array(2) {
      [6]=> string(5) "key_6"
      ["some_key"]=> string(14) "some_key_value"
    }
  }
}

```

### Decode file

[](#decode-file)

```
$data = Ini::decodeFile($iniFile);
```

Encode
------

[](#encode)

Encode data to INI string.

```
$data = [
    'key0' => 'val0',
    'key1' => 'val1',
    'key2' => 'val2',
    'key3' => 'val3',
    'key4' => 'val4',
    'arrKey' => [
        'abc',
        'def',
    ],
];

$iniString = Ini::encode($data);
echo $iniString;
```

**Output**:

```
key0 = val0
key1 = val1
key2 = val2
key3 = val3
key4 = val4
arrKey = [abc, def]
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance66

Regular maintenance activity

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~314 days

Total

5

Last Release

337d ago

PHP version history (2 changes)v0.1.0PHP &gt;8.0

v0.1.4PHP &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 (30 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")

---

Tags

encoderini-parserini-writerphpphp-inilibraryiniphp\_iniini-parser

### Embed Badge

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

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

###  Alternatives

[filp/whoops

php error handling for cool kids

13.3k394.4M1.3k](/packages/filp-whoops)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k488.3M21.1k](/packages/mockery-mockery)[league/iso3166

ISO 3166-1 PHP Library

69435.7M104](/packages/league-iso3166)[inhere/php-validate

generic data validate, filter library of the php

26786.7k12](/packages/inhere-php-validate)[phppkg/config

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

133.5k](/packages/phppkg-config)

PHPackages © 2026

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