nette/neon

🍸 Nette NEON: encodes and decodes NEON file format.

v3.0.0-beta1 2017-02-02 01:20 UTC

README

Downloads this Month Build Status Coverage Status Latest Stable Version License

NEON is very similar to YAML.The main difference is that the NEON supports "entities" (so can be used e.g. to parse phpDoc annotations) and tab characters for indentation. NEON syntax is a little simpler and the parsing is faster.

Try NEON in sandbox

Example of Neon code:

# my web application config

php:
	date.timezone: Europe/Prague
	zlib.output_compression: yes  # use gzip

database:
	driver: mysql
	username: root
	password: beruska92

users:
	- Dave
	- Kryten
	- Rimmer

Usage

Install it using Composer:

composer require nette/neon

The last stable release requires PHP version 5.6 or newer (is compatible with PHP 7.0 and 7.1). The dev-master version requires PHP 7.0.

Nette\Neon\Neon is a static class for encoding and decoding NEON files.

Neon::encode() returns $value encoded into NEON. Flags accepts Neon::BLOCK which formats NEON in multiline format.

use Nette\Neon\Neon;
$neon = Neon::encode($value); // Returns $value encoded in NEON
$neon = Neon::encode($value, Neon::BLOCK); // Returns formatted $value encoded in NEON

Neon::decode() converts given NEON to PHP value:

$value = Neon::decode('hello: world'); // Returns an array ['hello' => 'world']

Both methods throw Nette\Neon\Exception on error.

Editors plugins

Other languages