PHPackages                             jelix/inifile - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. jelix/inifile

ActiveLibrary[File &amp; Storage](/categories/file-storage)

jelix/inifile
=============

classes to read and modify ini files by preserving comments and empty lines

v3.4.0(2y ago)6133.5k↓19.3%3[1 PRs](https://github.com/jelix/inifile/pulls)1LGPL-2.1PHPPHP &gt;=5.6.1CI failing

Since Jun 1Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/jelix/inifile)[ Packagist](https://packagist.org/packages/jelix/inifile)[ Docs](http://jelix.org)[ RSS](/packages/jelix-inifile/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (26)Used By (1)

Some classes to read and modify ini files by preserving comments, empty lines.

They supports sections and array values. You can also merge sections, merge two ini files, and rename some values or sections.

installation
============

[](#installation)

You can install it from Composer. In your project:

```
composer require "jelix/inifile"

```

Usage
=====

[](#usage)

The `\Jelix\IniFile\IniModifier` class allows to read an ini file, to modify its content, and save it by preserving its comments and empty lines.

Don't use this class to just read content. Use instead `\Jelix\IniFile\Util` or `parse_ini_file()` for this purpose, it's more efficient and performant.

```
$ini = new \Jelix\IniFile\IniModifier('myfile.ini');

// setting a parameter.  (section_name is optional)
$ini->setValue('parameter_name', 'value', 'section_name');

// retrieve a parameter value. (section_name is optional)
$val = $ini->getValue('parameter_name', 'section_name');

// remove a parameter
$ini->removeValue('parameter_name', 'section_name');

// save into file

$ini->save();
$ini->saveAs('otherfile.ini');

// importing an ini file into an other
$ini2 = new \Jelix\IniFile\IniModifier('myfile2.ini');
$ini->import($ini2);
$ini->save();

// merging two section: merge sectionSource into sectionTarget and then
// sectionSource is removed
$ini->mergeSection('sectionSource', 'sectionTarget');
```

It supports also array values (indexed or associative) like :

```
foo[]=bar
foo[]=baz
assoc[key1]=car
assoc[otherkey]=bus

```

Then in PHP:

```
$ini = new \Jelix\IniFile\IniModifier('myfile.ini');

$val = $ini->getValue('foo'); // array('bar', 'baz');
$val = $ini->getValue('assoc'); // array('key1'=>'car', 'otherkey'=>'bus');

$ini->setValue('foo', 'other value', 0, '');
$val = $ini->getValue('foo'); // array('bar', 'baz', 'other value');

$ini->setValue('foo', 'five', 0, 5);
$val = $ini->getValue('foo'); // array('bar', 'baz', 'other value', 5 => 'five');

$ini->setValue('assoc', 'other value', 0, 'ov');
$val = $ini->getValue('assoc'); // array('key1'=>'car', 'otherkey'=>'bus', 'ov'=>'other value');

```

After saving, the ini content is:

```
foo[]=bar
foo[]=baz
assoc[key1]=car
assoc[otherkey]=bus

foo[]="other value"
foo[]=five
assoc[ov]="other value"

```

Note: the result can be parsed by `parse_ini_file()`.

See the class to learn about other methods and options.

The `\Jelix\IniFile\MultiIniModifier` allows to load two ini files at the same time, where the second one "overrides" values of the first one.

The `\Jelix\IniFile\IniModifierArray` allows to load several files at the same time, and to manage their values as if files were merged.

The `\Jelix\IniFile\Util` contains simple methods to read, write and merge ini files. These are just wrappers around `parse_ini_file()`.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity68

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

Recently: every ~207 days

Total

25

Last Release

871d ago

Major Versions

v1.7.1 → v2.0.02016-11-29

v2.5.0 → v3.0.02018-10-24

PHP version history (3 changes)v1.7.0PHP &gt;=5.3.3

v2.1.0PHP &gt;=5.6.0

v3.2.0PHP &gt;=5.6.1

### Community

Maintainers

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

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

---

Top Contributors

[![laurentj](https://avatars.githubusercontent.com/u/336034?v=4)](https://github.com/laurentj "laurentj (73 commits)")[![julieni](https://avatars.githubusercontent.com/u/995738?v=4)](https://github.com/julieni "julieni (1 commits)")

---

Tags

filesini

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jelix-inifile/health.svg)

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k679.9M2.5k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

225267.1M89](/packages/league-flysystem-local)[mikehaertl/php-tmpfile

A convenience class for temporary files

9732.3M21](/packages/mikehaertl-php-tmpfile)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8737.3M276](/packages/league-flysystem-memory)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M63](/packages/creocoder-yii2-flysystem)

PHPackages © 2026

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