Matomo Ini

A PHP library to read and write INI configuration files with real typing and exceptions.

Library
Composer
v3.0.3
51 stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
50 /100 Fair
Development Activity 48
Maintenance 36
Community 44
Maturity 60
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
72 /100 Good
Architecture 72
Code Quality 74
Innovation 58
Learning Curve 82

Matomo Ini is a PHP component for reading and writing INI configuration files that improves on PHP’s built-in parse_ini_file(). Where the native function only reads, returns weakly-typed strings, and emits PHP errors, Matomo Ini can also write INI files, parses booleans and numbers into real PHP types, and throws exceptions you can catch.

Because reading and writing are exposed as injectable classes rather than global functions, they can be passed as dependencies and mocked in unit tests, making configuration handling first-class and testable in modern application code.

What You Get

  • An IniReader that parses INI files and strings into typed PHP arrays
  • An IniWriter that serializes PHP arrays back into INI format
  • Automatic parsing of boolean and numeric values into real PHP types
  • Dedicated IniReadingException and IniWritingException for error handling
  • Injectable, mockable classes instead of global functions

Common Use Cases

  • Loading application configuration from INI files with correct types
  • Programmatically writing or updating INI configuration files
  • Validating configuration input and catching parse errors as exceptions
  • Mocking configuration reads and writes in unit tests

Under The Hood

Architecture - The component is four classes in src/: IniReader and IniWriter provide the read/write surface, while IniReadingException and IniWritingException represent failure modes. IniReader normalises raw INI values into typed PHP scalars, and IniWriter performs the inverse, producing INI text from a PHP array. Because both are plain objects rather than static helpers, they slot cleanly into dependency-injection containers.

Tech Stack - Pure PHP (>=7.2) with PSR-4 autoloading under Matomo\Ini\ and no runtime dependencies. The project ships PHPUnit tests and a phpbench.json for benchmarking.

Code Quality - The code is compact, single-responsibility, and covered by a dedicated tests/ directory, with explicit exception types making error paths clear. It is a mature, stable component rather than one under active feature development.

API Design - The API is intuitive: instantiate a reader or writer and call a read/write method. Typed return values and thrown exceptions mean callers avoid the string-coercion and error-suppression pitfalls of parse_ini_file(), with almost no boilerplate.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers