PHPackages                             programie/pini - 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. programie/pini

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

programie/pini
==============

A simple PHP class for reading and writing ini files

1.4(7y ago)02.9kMITPHPCI passing

Since Jan 14Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Programie/Pini)[ Packagist](https://packagist.org/packages/programie/pini)[ RSS](/packages/programie-pini/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (6)Used By (0)

Pini
====

[](#pini)

A simple PHP class for reading and writing ini files.

[![License](https://camo.githubusercontent.com/849c86f774a852d83216711812f833a15e28c44ba3b5101c3384101df4483ac3/68747470733a2f2f706f7365722e707567782e6f72672f70726f6772616d69652f70696e692f6c6963656e73652e737667)](https://packagist.org/packages/programie/pini)[![Latest Stable Version](https://camo.githubusercontent.com/22a0e774bf64f9da1cc450a01d8c742ee5dc62e56a3756be80a6f2c99ee84590/68747470733a2f2f706f7365722e707567782e6f72672f70726f6772616d69652f70696e692f762f737461626c652e737667)](https://packagist.org/packages/programie/pini)[![Latest Unstable Version](https://camo.githubusercontent.com/21729b3c3810188470f2566d19f781dd55e8ea72fc94fa5d84ce8686b9ebbccb/68747470733a2f2f706f7365722e707567782e6f72672f70726f6772616d69652f70696e692f762f756e737461626c652e737667)](https://packagist.org/packages/programie/pini)[![Total Downloads](https://camo.githubusercontent.com/99e863d1803a4837607e0b62d8c321ba4a5556a20165bef05e096709c01807d8/68747470733a2f2f706f7365722e707567782e6f72672f70726f6772616d69652f70696e692f646f776e6c6f6164732e737667)](https://packagist.org/packages/programie/pini)[![codecov](https://camo.githubusercontent.com/c04da13a8d584dd5943e583832e71e50a4ff259ca9f1d3145c9cc955d9693ccd/68747470733a2f2f636f6465636f762e696f2f6769746875622f50726f6772616d69652f50696e692f67726170682f62616467652e7376673f746f6b656e3d756b4d64476130656f53)](https://codecov.io/github/Programie/Pini)

Installation
------------

[](#installation)

Add the composer package "programie/pini" to the required packages of your composer.json:

```
composer require programie/pini
```

Examples
--------

[](#examples)

### Parse ini and read values

[](#parse-ini-and-read-values)

```
$ini = new Pini("/path/to/your/file.ini");

$ini->getValue("section name", "key name");// Returns the value of the key "key name" in section "section name"
```

### Merge sections and values from another ini file

[](#merge-sections-and-values-from-another-ini-file)

Sometimes you want to merge sections and their keys from multiple ini files into one (e.g. if you want to provide default values as an ini file).

This can be done using the merge() method. It will replace all keys with the keys from the given ini file.

```
$ini1 = new Pini("/path/to/your/first.ini");

$ini2 = new Pini("/path/to/your/second.ini");

$ini1->merge($ini2);
```

$ini1 will now contain all sections and keys from $ini2. An already existing key will be replaced with the key from the second ini file.

You may also specify the section you want to merge.

```
$ini1->merge($ini2, "section name");
```

This will only merge keys from the given section from $ini2 into $ini1.

### Write values and save ini

[](#write-values-and-save-ini)

With Pini you are also able to write ini files.

```
$ini = new Pini();

$ini->setValue("section name", "key name", "some value");

$ini->save("/path/to/your/file.ini");
```

This will add or replace the key "key name" in the section "section name" with the value "some value".

The save() method saves the whole content of the Pini instance to a file.

Note: The $filename parameter in the save() method is optional. The filename passed on instance creation is used by default.

```
$ini = new Pini("/path/to/your/file.ini");

// ... Some other ini methods.

$ini->save();
```

This will save the content to the file passed on instance creation ("/path/to/your/file.ini").

Look at the examples folder for more examples.

Structure
---------

[](#structure)

An ini file can has the following structure:

```
[section name]
property key = property value
another property = another value
array property[] = some value
array property[] = another value

[another section]
another property = even another value
```

Ini files contain multiple sections. Each section can contain multiple properties.

A property key ending with "\[\]" defines an array. Define multiple same named array properties (e.g. "property\[\]") with any value to add values to the array.

Non-array properties with the same key already defined in the section will replace the previously defined property.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance53

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% 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 ~368 days

Total

5

Last Release

2670d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b1cdb4cff17db3774d5a1c9197d5dc04bd22b2d3ec3c457381f3ffe44d6d15f?d=identicon)[Programie](/maintainers/Programie)

---

Top Contributors

[![Programie](https://avatars.githubusercontent.com/u/1206521?v=4)](https://github.com/Programie "Programie (69 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

inioopparserphp-libraryreaderwriter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/programie-pini/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

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

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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