2017 © Pedro Peláez
 

library toml

A parser for TOML implemented in PHP.

image

jamesmoss/toml

A parser for TOML implemented in PHP.

  • Thursday, February 27, 2014
  • by jamesmoss
  • Repository
  • 1 Watchers
  • 30 Stars
  • 7,806 Installations
  • PHP
  • 15 Dependents
  • 13 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 7 % Grown

The README.md

TOML for PHP

Build Status, (*1)

A parser for 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)., (*2)

Requirements

  • PHP 5.3
  • Composer

Installation

Use Composer to install the Toml package. Package details can be found on Packagist.org., (*3)

Add the following to your composer.json and run composer update., (*4)

"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., (*5)

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., (*6)

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

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

$ composer update
$ phpunit

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., (*8)

Todo

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

The Versions

27/02 2014

dev-lexer

dev-lexer http://github.com/jamesmoss/toml

A parser for TOML implemented in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

toml github mojombo

25/02 2014

dev-master

9999999-dev http://github.com/jamesmoss/toml

A parser for TOML implemented in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

toml github mojombo

25/02 2014

1.1.1

1.1.1.0 http://github.com/jamesmoss/toml

A parser for TOML implemented in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

toml github mojombo

27/02 2013

0.1.0

0.1.0.0 http://github.com/jamesmoss/toml

A parser for TOML implemented in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

toml github mojombo