PHPackages                             hypnotox/toml - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hypnotox/toml

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hypnotox/toml
=============

A PHP package implementing a TOML file loader.

v1.0.1(1mo ago)143MITPHPPHP &gt;=8.3CI passing

Since Mar 25Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hypnotox/php-toml)[ Packagist](https://packagist.org/packages/hypnotox/toml)[ RSS](/packages/hypnotox-toml/feed)WikiDiscussions main Synced 1mo ago

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

hypnotox/toml
=============

[](#hypnotoxtoml)

[![CI Status](https://github.com/hypnotox/php-toml/actions/workflows/ci.yml/badge.svg)](https://github.com/hypnotox/php-toml)[![Code Coverage](https://camo.githubusercontent.com/15ad41b3a7eb22de6ed0117244de56be384b47db88a757f7680ae5646adf8883/68747470733a2f2f636f6465636f762e696f2f67682f6879706e6f746f782f7068702d746f6d6c2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d467273646c4f4962526f)](https://codecov.io/gh/hypnotox/php-toml)[![Packagist Version](https://camo.githubusercontent.com/6fbf4c3be90c55d9d570801f5e90725fcf7e95c9468bacf174bc14e747b03558/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f6879706e6f746f782f746f6d6c)](https://packagist.org/packages/hypnotox/toml)[![Packagist PHP Version Support](https://camo.githubusercontent.com/0cc7b42b316da27ed6afb29d5d18fcf9016e2b3387004b32bc2c976c83d5a60c/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f6879706e6f746f782f746f6d6c)](https://packagist.org/packages/hypnotox/toml)[![GitHub](https://camo.githubusercontent.com/f8ea282ac618ff6e3dfe5d91877d09a78224a01c16ac7952bbad6f370f02a890/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f6879706e6f746f782f746f6d6c)](/LICENSE.md)

A PHP package for encoding and decoding TOML with immutable object representation.

Fully supports the [TOML v1.0.0 specification](https://toml.io/en/v1.0.0) and passes the [toml-test](https://github.com/toml-lang/toml-test) conformance suite (678 decoder tests + 205 encoder tests).

Requires PHP 8.3+.

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

[](#installation)

```
composer require hypnotox/toml
```

Usage
-----

[](#usage)

### Decoding TOML

[](#decoding-toml)

```
use HypnoTox\Toml\TomlFactory;

$factory = new TomlFactory();
$toml = $factory->fromString('
[server]
host = "localhost"
port = 8080
enabled = true
');

$toml->get('server.host');    // "localhost"
$toml->get('server.port');    // 8080
$toml->get('server.enabled'); // true
$toml->toArray();             // ['server' => ['host' => 'localhost', 'port' => 8080, 'enabled' => true]]
```

### Encoding to TOML

[](#encoding-to-toml)

```
use HypnoTox\Toml\Toml;

$toml = Toml::fromArray([
    'title' => 'My App',
    'database' => [
        'host' => '127.0.0.1',
        'port' => 5432,
        'enabled' => true,
    ],
]);

echo $toml->toString();
// title = "My App"
//
// [database]
// host = "127.0.0.1"
// port = 5432
// enabled = true
```

### Working with Toml objects

[](#working-with-toml-objects)

```
// Immutable set (returns a new instance)
$updated = $toml->set('server.host', '0.0.0.0');

// Get as PHP array
$array = $toml->toArray();

// Encode back to TOML string
$string = $toml->toString();
```

Features
--------

[](#features)

- Full TOML v1.0.0 specification support
    - Tables, inline tables, array of tables
    - All key types (bare, quoted, dotted)
    - All data types: string (basic, literal, multiline), integer (decimal, hex, octal, binary), float (including inf/nan), boolean, offset date-time, local date-time, local date, local time, array
- Bidirectional: decode TOML to PHP arrays and encode PHP arrays to TOML
- Immutable `Toml` data objects
- Strict validation with detailed error messages including line/column numbers

License
-------

[](#license)

[MIT](/LICENSE.md)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

2

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b5b9c61f4243d23e766c730ef4f2590d718befb32bcaf91cc18d14566d588c0?d=identicon)[hypnotox](/maintainers/hypnotox)

---

Top Contributors

[![hypnotox](https://avatars.githubusercontent.com/u/47070257?v=4)](https://github.com/hypnotox "hypnotox (61 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hypnotox-toml/health.svg)

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

PHPackages © 2026

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