Download the PHP package nette/neon without Composer

On this page you can find all versions of the php package nette/neon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package neon

NEON

Downloads this Month Tests Coverage Status Latest Stable Version License

 <!---->

Introduction

NEON is a human-readable structured data format. In Nette, it is used for configuration files. It is also used for structured data such as settings, language translations, etc. Try it on the sandbox.

NEON stands for Nette Object Notation. It is less complex and ungainly than XML or JSON, but provides similar capabilities. It is very similar to YAML. The main advantage is that NEON has so-called entities, thanks to which the configuration of DI services is so sexy. And allows tabs for indentation.

NEON is built from the ground up to be simple to use.

 <!---->

Support Neon

Do you like NEON? Are you looking forward to the new features?

Buy me a coffee

Thank you!

 <!---->

Usage

Install via Composer:

It requires PHP version 8.0 up to 8.4. Documentation can be found on the website.

Neon::encode() returns $value converted to NEON. As the second parameter $blockMode you can pass true, which will create multiline output. The third parameter $indentation specifies the characters used for indentation (default is tab).

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

Neon::decodeFile() converts given NEON file to PHP value:

All methods throw Nette\Neon\Exception on error.

 <!---->

Integration

You can check for syntax errors in Neon files using the neon-lint console command:

 <!---->

Syntax

A file written in NEON usually consists of a sequence or mapping.

Mappings

Mapping is a set of key-value pairs, in PHP it would be called an associative array. Each pair is written as key: value, a space after : is required. The value can be anything: string, number, boolean, null, sequence, or other mapping.

In PHP, the same structure would be written as:

This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for mapping, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:

This is the same written on multiple lines (indentation does not matter):

Alternatively, = can be used instead of : , both in block and inline notation:

Sequences

Sequences are indexed arrays in PHP. They are written as lines starting with the hyphen - followed by a space. Again, the value can be anything: string, number, boolean, null, sequence, or other mapping.

In PHP, the same structure would be written as:

This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for sequences, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:

This is the same written on multiple lines (indentation does not matter):

Hyphens cannot be used in an inline representation.

Combination

Values of mappings and sequences may be other mappings and sequences. The level of indentation plays a major role. In the following example, the hyphen used to indicate sequence items has a greater indent than the pets key, so the items become the value of the first line:

In PHP, the same structure would be written as:

It is possible to combine block and inline notation:

Block notation can no longer be used inside an inline notation, this does not work:

In the previous case, we wrote a mapping whose elements were sequences. Now, let's try it the other way around and create a sequence containing mappings:

It's not necessary for the bullet points to be on separate lines; they can also be placed in this manner:

It's up to you whether you align the keys in a column using spaces or a tab.

Because PHP uses the same structure for mapping and sequences, that is, arrays, both can be merged. The indentation is the same this time:

In PHP, the same structure would be written as:

Strings

Strings in NEON can be enclosed in single or double quotes. But as you can see, they can also be without quotes.

If the string contains characters # " ' , : = - [ ] { } ( ) that can be confused with NEON syntax, it must be enclosed in quotation marks. We recommend using single quotes because they do not use escaping. If you need to enclose a quotation mark in such a string, double it:

Double quotes allow you to use escape sequences to write special characters using backslashes \. All escape sequences as in the JSON format are supported, plus \_, which is an non-breaking space, ie \u00A0.

There are other cases where you need to enclose strings in quotation marks:

Multiline Strings

A multiline string begins and ends with a triple quotation mark on separate lines. The indent of the first line is ignored for all lines:

In PHP we would write the same as:

Escaping sequences only work for strings enclosed in double quotes instead of apostrophes:

Numbers

NEON understands numbers written in so-called scientific notation and also numbers in binary, octal and hexadecimal:

Nulls

Null can be expressed in NEON by using null or by not specifying a value. Variants with a capital first or all uppercase letters are also allowed.

Booleans

Boolean values are expressed in NEON using true / false or yes / no. Variants with a capital first or all uppercase letters are also allowed.

Dates

NEON uses the following formats to express data and automatically converts them to DateTimeImmutable objects:

Entities

An entity is a structure that resembles a function call:

In PHP, it is parsed as an object Nette\Neon\Entity:

Entities can also be chained:

Which is parsed in PHP as follows:

Inside the parentheses, the rules for inline notation used for mapping and sequences apply, so it can be divided into several lines and it is not necessary to add commas:

Comments

Comments start with # and all of the following characters on the right are ignored:

NEON Versus JSON

JSON is a subset of NEON. Each JSON can therefore be parsed as NEON:

What if we could omit quotes?

How about braces and commas?

Are bullets more legible?

How about comments?

You found NEON syntax!

If you like NEON, please make a donation now. Thank you!


All versions of neon with dependencies

PHP Build Version
Package Version
Requires php Version 8.0 - 8.4
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nette/neon contains the following files

Loading the files please wait ....