Movatterモバイル変換


[0]ホーム

URL:


Nette NEON

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 theNEON format andtry itout.

All examples assume the following alias is defined:

use Nette\Neon\Neon;

Installation

Download and install the package usingComposer:

composer require nette/neon

You can check for syntax errors in*.neon files using theneon-lint console command:

vendor/bin/neon-lint <path>

encode(mixed $value,bool $blockMode=false,string $indentation="\t")string

Returns$value converted to NEON. You can passtrue to the$blockMode parameter tocreate multiline output. The$indentation parameter specifies the characters used for indentation (defaultis tab).

Neon::encode($value); // Returns $value converted to NEONNeon::encode($value, true); // Returns $value converted to multiline NEON

Theencode() method throwsNette\Neon\Exception on error.

try {$neon = Neon::encode($value);} catch (Nette\Neon\Exception $e) {// Exception handling}

decode(string $neon):mixed

Converts the given NEON string to a PHP value.

Returns scalars, arrays,dates as DateTimeImmutable objects, andentities asNette\Neon\Entity objects.

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

Thedecode() method throwsNette\Neon\Exception on error.

try {$value = Neon::decode($neon);} catch (Nette\Neon\Exception $e) {// Exception handling}

decodeFile(string $file)mixed

Converts the contents of a file from NEON to PHP and removes any BOM.

Neon::decodeFile('config.neon');

ThedecodeFile() method throwsNette\Neon\Exception on error.

  1. Documentation
  2. Nette NEON
version:3.42.x

[8]ページ先頭

©2009-2025 Movatter.jp