This is very much WIP. Do not use in production, maybe don't even call it a TOML parser just yet ;-)
Open a shell, cd
to your poject and type:
composer require malc0mn/php-toml-processor dev-master
or edit composer.json and add:
{
"require": {
"malc0mn/php-toml-processor": "~1.0"
}
}
$config = Toml::fromFile('config.toml')->toArray();
$toml = Toml::fromFile('config.toml')->prettyPrint(-1);
// Or like this
$toml = (string)Toml::fromFile('config.toml');
$toml = Toml::fromFile('/path/to/config.toml');
// Do stuff with $toml... Some fancy helper methods will be added soon.
// Or like this
$toml->saveToFile('/path/to/config.toml');
The basic setup is based on Roman Piták's Nginx Config Processor which I personally like very much! Thanks for that @romanpitak! Credits were left in the files I re-used and modified.
I also used the Doctrine Lexer class which
I simply included as I did not want to add a dependency for a single file. I
also added an additional method (IMHO: a mistake in the Doctrine Lexer is a
missing setter for the position
property. Not for the faint of heart, but it
would make the lexer completely extendable)...
Thanks to @doctrine for that one!
This repo was created by integr.io for use in one of our Symfony applications.