NEON Functions
NEON is a human-friendly data serialization language. It is used in Nette for configuration files. Nette\Neon\Neon is a static class for working with NEON.
Get to know NEON format and try it out.
The following examples use these aliases:
Installation
Download and install the package using Composer:
You can check for syntax errors in *.neon
files using the neon-lint
console command:
encode(mixed $value, bool $blockMode=false,
string $indentation="\t"
): string
Returns $value
converted to NEON. As the parameter $blockMode
you can pass true, which will create
multiline output. The parameter $indentation
specifies the characters used for indentation (default is tab).
Method encode()
throws Nette\Neon\Exception
on error.
decode(string $neon): mixed
Converts given NEON to PHP value.
Returns scalars, arrays, date as DateTimeImmutable objects, and entities as Nette\Neon\Entity objects.
Method decode()
throws Nette\Neon\Exception
on error.
decodeFile(string $file): mixed
Converts the contents of the file from NEON to PHP and removes any BOM.
Method decodeFile()
throws Nette\Neon\Exception
on error.