PHPackages                             jamesmoss/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jamesmoss/toml

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

jamesmoss/toml
==============

A parser for TOML implemented in PHP.

1.1.1(12y ago)3231.5k[1 issues](https://github.com/jamesmoss/toml/issues)15MITPHPPHP &gt;=5.3.0

Since Feb 27Pushed 12y ago1 watchersCompare

[ Source](https://github.com/jamesmoss/toml)[ Packagist](https://packagist.org/packages/jamesmoss/toml)[ Docs](http://github.com/jamesmoss/toml)[ RSS](/packages/jamesmoss-toml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (15)

TOML for PHP
============

[](#toml-for-php)

[![Build Status](https://camo.githubusercontent.com/cca99fa656988682183751e592878aabca372cf2a71d2dbcf8caec02f3ec16ca/68747470733a2f2f7472617669732d63692e6f72672f6a616d65736d6f73732f746f6d6c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/jamesmoss/toml)

A parser for [TOML](https://github.com/mojombo/toml) written in PHP. Currently supports 100% of the TOML spec: dates, multiline arrays, key groups - the lot (including all of the more minor restrictions such as same-type arrays and key group override rules).

Requirements
------------

[](#requirements)

- PHP 5.3
- Composer

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

[](#installation)

Use [Composer](http://getcomposer.org/) to install the Toml package. Package details [can be found on Packagist.org](https://packagist.org/packages/jamesmoss/toml).

Add the following to your `composer.json` and run `composer update`.

```
"require": {
	//...
    "jamesmoss/toml": "dev-master"
}

```

You can use this lib without Composer but you'll need to provide your own PSR-0 compatible autoloader. Really, you should just use Composer.

Use
---

[](#use)

`Toml\Parser` has two static methods `fromString` and `fromFile`, which are self explanatory. Both return an associative array. If your TOML doc can't be parsed an `Exception` will be thrown with a useful error message.

```
use Toml\Parser;

// Load directly from a string
$toml = Parser::fromString('name = "James Moss"');

var_dump($toml['name']); // outputs 'James Moss'.

// Load from a file instead
$toml = Parser::fromFile(__DIR__ . '/config.toml');

```

Running tests
-------------

[](#running-tests)

There is 100% test coverage at the moment. If you'd like to run the tests yourself, use the following:

```
$ composer update
$ phpunit

```

Contributing
------------

[](#contributing)

The TOML spec is changing often as it's in its infancy; if you spot something I've missed fork this repo, create a new branch and submit a pull request. Make sure any features you add are covered by unit tests.

Todo
----

[](#todo)

- Better documentation and docblocks
- More semantic exceptions to be thrown, standardise the error message format.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

2

Last Release

4465d ago

Major Versions

0.1.0 → 1.1.12014-02-25

### Community

Maintainers

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

---

Tags

githubtomlmojombo

### Embed Badge

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

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

###  Alternatives

[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k404.0M702](/packages/league-commonmark)[yosymfony/toml

A PHP parser for TOML compatible with specification 0.4.0

2081.7M71](/packages/yosymfony-toml)[ion-bazan/composer-diff

Compares composer.lock changes and generates Markdown report so you can use it in PR description.

1861.8M3](/packages/ion-bazan-composer-diff)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.2k1](/packages/m1-vars)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

266.7k](/packages/leonelquinteros-php-toml)[devium/toml

A PHP encoder/decoder for TOML compatible with specification 1.0.0

3968.9k13](/packages/devium-toml)

PHPackages © 2026

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