neon sandbox

NEON for PHP for JavaScript for Python

…or install using composer install nette/neon

NetBeans IDE has built-in support, check out NEON plugin for PhpStorm and Visual Studio Code.

array (7)
name => "Homer" (5) address => array (3)
| street => "742 Evergreen Terrace" (21) | city => "Springfield" (11) | country => "USA" (3)
phones => array (2)
| home => "555-6528" (8) | work => "555-7334" (8)
children => array (3)
| 0 => "Bart" (4) | 1 => "Lisa" (4) | 2 => "Maggie" (6)
entity => Nette\Neon\Entity #dc53
| value => "Column" (6) | attributes => array (2)
| | type => "int" (3) | | nulls => TRUE
string => "characters like #()= put in quotes" (34) multi => "one line second line third line" (31)

Configuration written in PHP?

$config = array(
    'php' => array(
        'date.timezone' => 'Europe/Prague',
        'zlib.output_compression' => true,
    ),
    'database' => array(
        'driver' => 'mysql',
        'username' => 'root',
        'password' => 'beruska92',
    ),
    'users' => array(
        'Dave',
        'Kryten',
        'Rimmer',
    ),
);

Or is it better to use JSON?

{
"php": {
    "date.timezone": "Europe\/Prague",
    "zlib.output_compression": true
},
"database": {
    "driver": "mysql",
    "username": "root",
    "password": "beruska92"
},
"users": [
    "Dave", "Kryten", "Rimmer"
]
}

What if we could omit quotes?

{
php: {
    date.timezone: Europe/Prague,
    zlib.output_compression: true
},
database: {
    driver: mysql,
    username: root,
    password: beruska92
},
users: [
    Dave, Kryten, Rimmer
]
}

How about braces and commas?

php:
    date.timezone: Europe/Prague
    zlib.output_compression: true

database:
    driver: mysql
    username: root
    password: beruska92

users: [
    Dave, Kryten, Rimmer
]

Are bullets more legible?

php:
    date.timezone: Europe/Prague
    zlib.output_compression: true

database:
    driver: mysql
    username: root
    password: beruska92

users:
    - Dave
    - Kryten
    - Rimmer

How about comments?

# 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

You found NEON syntax!

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.