Git Product home page Git Product logo

neon's Introduction

Nette Framework is a popular tool for PHP web development. It is designed to be as usable and as friendly as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks.

Nette Framework speaks your language and helps you to easily build better websites.

The Quick Start tutorial gives you a first introduction to the framework by creating a simple database driven application.

Over 10 Yrs of Development

We have been developing Nette for over 10 years- and counting! Libraries we provide are therefore highly mature, stable and widely used. They are trusted by a number of global corporations and many significant websites rely on us.

Catching Bronze

We aim to create Nette as a fun and easy to use framework, that programmers can fall in love with. And we seem to be doing it well! We were rated as the 3rd most popular framework in a survey Best PHP Framework for 2015 by a well-know magazine SitePoint.

Security Is a Priority

There is nothing we care about more than security. That is why we had built Nette as the safest PHP framework. It had passed many audits with flying colours, it eliminates safety traps like XSS, CSRF and brings out ground-breaking methods.

Libraries & Framework

Nette consists of a number of handy standalone libraries, which can be used in any codebase, for example combined with WordPress or another framework. Careful, some of them are highly addictive! These are the components that Nette Framework is built on:

  • Application – The kernel of web application
  • Bootstrap – Bootstrap of your application
  • Caching – Cache layer with set of storages
  • Component Model – Foundation for component systems
  • DI – Dependency Injection Container
  • Finder – Find files and directories with an intuitive API
  • Database – Database layer
  • Forms – Greatly facilitates secure web forms
  • Http – Layer for the HTTP request & response
  • Latte – Amazing template engine
  • Mail – Sending E-mails
  • Neon – Loads and dumps NEON format
  • Php Generator – PHP code generator
  • Robot Loader – The most comfortable autoloading
  • Routing – Routing
  • Safe Stream – Safe atomic operations with files
  • Security – Provides access control system
  • Schema – User data validation
  • Tester – Enjoyable unit testing in PHP
  • Tracy – Debugging tool you will love ♥
  • Tokenizer – Source code tokenizer
  • Utils – Utilities and Core Classes

neon's People

Contributors

andares avatar ccampos avatar clxmstaab avatar dg avatar f3l1x avatar fprochazka avatar janbarasek avatar jantvrdik avatar matej21 avatar pepakriz avatar sallyx avatar vjirovsky avatar vrana avatar xsuchy09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neon's Issues

leading zeros trimmed from numeric string

Hi, is trimming leading zeros from numeric string a feature or a bug?

- 0907123456

valid mobile number gets parsed as 907123456 integer. I know I can use quotes to parse it as string. I was just used to not having to use quotes in neon syntax. If this is a feature it could help someone else if it was mentioned in docs

Escaping single quotes

I'd like include a regexp version of
Strict comparison using === between 'OBJECT'|PhpParser\Node\Expr and 'ARRAY_A' will always evaluate to false. in @phpstan 's config.

This is invalid.

message: '#^Strict comparison using === between 'OBJECT'\|PhpParser\\Node\\Expr and 'ARRAY_A' will always evaluate to false\.$#'

Please advise.

Possibility to replace whole array by another one

Several times we had to replace array by another array instead of merging them:

For example:

[default]
    test: [a,b,c,d]
[test < default]
    test: [b,f,m,l]

And we need to give array('b', 'f', 'm', 'l') instead of array('a', 'b', 'c', 'd','f', 'm', 'l')

It could be useful to have possibility to "force replace" for example: using prefix before the array name.

[default]
    test: [a,b,c,d]
[test < default]
    !test: [b,f,m,l]

vim support

Hey all,

I couldn't find this in the forums, and googling for vim neon mostly gives me colorschemes: is there any known vim plugin to get syntax highlighting to work in .neon files?

RFC: Anchors, References, Extend

Prologue

I'd like to propose a new NEON features. I named them anchors, references, extend. It basically came from YAML (https://en.wikipedia.org/wiki/YAML#Syntax, https://blog.daemonl.com/2016/02/yaml.html).

When you are using NEON in nette-like applications, you are probably using it for service definitions. I consider current syntax as complete and don't miss anything.

However, when you are using NEON as standalone tool for some kind of definition schema, I found myself to miss some features like extending and referencing. I have 1000+ rows in one NEON file and DRY principle comes very handy in here.

Anchors & References

YAML

foo: &anchor
 K1: "One"
 K2: "Two"

bar: *anchor

Result

{
    "foo": {
        "K1": "One",
        "K2": "Two"
    },
    "bar": {
        "K1": "One",
        "K2": "Two"
    }
}

NEON

# A
foo: &anchor
bar: *anchor

# B
foo: &(anchor)
bar: $(anchor)

# C
foo: =$(anchor)
bar: $(anchor)

& and * has no special meaning in NEON, am I right?

Extending

YAML

foo: &anchor
  K1: "One"
  K2: "Two"

bar:
  <<: *anchor
  K2: "I Changed"
  K3: "Three"

Result

{
    "foo": {
        "K1": "One",
        "K2": "Two"
    },
    "bar": {
        "K1": "One",
        "K2": "I Changed",
        "K3": "Three"
    }
}

NEON

# A
foo: # depends on anchor 
bar: <<$anchor

# B
foo: # depends on anchor
bar: ...$anchor

It's an idea of adding extra features to NEON. Maybe someone think the same way. Thanks for a feedback.


List of resources

Uncaught exception

When I did a typo in a file like "q" on the last line:

Fatal error: Uncaught exception 'Nette\Neon\Exception' with message 'Unexpected 'end' on line 71, column 2.' in /Neon/Decoder.php:329

RFC: Group array values declaration

  • bug report? no
  • feature request? yes

Description

I don't think there is super big chance for this feature, but let's try it... :) As you know in PHP it's possible to use group declarations for namespaces. I found it very useful. And now I am missing this syntax in NEON format. Instead of this:

services:
  - Adeira\Connector\Devices\Application\Service\WeatherStation\AddWeatherStationRecordService
  - Adeira\Connector\Devices\Application\Service\WeatherStation\ViewAllWeatherStationsService
  - Adeira\Connector\Devices\Application\Service\WeatherStation\ViewSingleWeatherStationService

It would be awesome to write just this:

services:
  - Adeira\Connector\Devices\Application\Service\WeatherStation\{
      AddWeatherStationRecordService,
      ViewAllWeatherStationsService,
      ViewSingleWeatherStationService
    }

Also it opens new ways of configuring multiple services at once:

services:
  - class: Adeira\Connector\Devices\Application\Service\WeatherStation\{
      AddWeatherStationRecordService,
      ViewAllWeatherStationsService,
      ViewSingleWeatherStationService
    }
    arguments:
      transactionalSession: @doctrineSession
      ownerService: @userIdOwnerService

But I would be ok with just simple group format without possibilities to configure these services. Unfortunately it means that NEON syntax will be more complicated, but it should be without BC break (works only with [a-z]\\{ ...). What do you think? Or maybe it's just stupid idea... :)

This is maby more related to the Nette\DI package, but it's NEON syntax...

Parse ' - - ' string error

Version: 2.4.3

Bug Description

parse ' - - ' string in yaml error.

Expected Behavior

run the follow code:

use Nette\Neon\Neon;

$a = '
$query:
  - - same
    - id:     1
  - - case
    - isTop:  1
      fail:   1
$seek:
  - start/503102
  - field:  id
    take:   20
';
$result = Neon::decode(trim($a));

Encoder generates unneeded indentation and new lines

Let's have following messagess.neon file:

a:
    b: Some text
    c: Some other text
    d: someKey:
        e: Some next message
f: Hello world

We want to parse this file by Decoder, the decoded values encode by Encoder and save the file back, because we want fix "Neon coding standards" in this file. Like remove unneeded ",' etc...

The common problem is, that the Encoder properly fix the Neon coding standards, but generates also unneeded newlines and tabs.

Let's have following code:

$file = file_get_contents('messages.neon');
$decoder = new Decoder;
$decoded = $decoder->decode($file);
$encoder = new Encoder;
$encoded = $encoder->encode($decoded, Encoder::BLOCK);
file_put_contents('messages.neon', $encoded);

And the result of messages.neon?

a:
    b: Some text
    c: Some other text
    d: someKey:
        e: Some next message
        #two tabs
    #one tab
f: Hello world

Encoded DateTime incompatible with Decoder

DateTime representation in generated Neon isn't properly parsed as a DateTime-compatible string and is therefore decoded as a string instead of a DateTime instance.

This breaks stuff, as $data !== decode(encode($data)).

PHP 7.0.3 CLI from MacPorts.

$data = [
    'myDate' => new DateTime('2016-06-03T19:00:00+02:00'),
];

$neon = Nette\Neon\Neon::encode($data, Nette\Neon\Neon::BLOCK);
$decoded = Nette\Neon\Neon::decode($neon);

// Fatal error: Call to a member function format() on a string
$decoded['myDate']->format('Y-m-d H:i:s O');

The problem is that the encoder formats a DateTime using the Y-m-d H:i:s O format string; the O format character doesn't add a colon between the timezone offset's hours and minutes (unlike the P format character). The regular expression in the decoder won't match the string without the colon in the timezone offset (the specific part of the regexp in question being Z|[-+]\d\d?(?::\d\d)?).

Fixing this is as simple as putting a single question mark in the decoder regexp after the offending colon, making it Z|[-+]\d\d?(?::?\d\d)?. I'd fix this and send a PR, but I won't get around to doing it today..

Documentation: There is no grammar definition

  • bug report? yes
  • feature request? no
  • version: *

Description

There are few examples on website, but otherwise there is nothing else.

To fully understand the syntax of the file a grammar definitions are required. Take a look at http://json.org/ for a good example.

Steps To Reproduce

  1. Try to read the documentation.
  2. Bug: There is no documentation.

Provide way to escape single quote inside single quoted string

Version: 3.1.0

Bug Description

Cannot escape single quote inside single quoted string

Steps To Reproduce

'I''m'

Expected Behavior

Some way (ideally compatible with YAML) to escape single quotes inside single quoted strings

Possible Solution

Use double single quote (like YAML)

Maybe bug with nested array in Neon entity

  • bug report? probably

I assumed that the following three should be equal, yet they are not.

- App\Model\AnalyzersRegistry(analyzers: {phpstan: @App\Model\PhpStanAnalyzer})
- App\Model\AnalyzersRegistry(
	analyzers: {
		phpstan: @App\Model\PhpStanAnalyzer
	}
)
- App\Model\AnalyzersRegistry(
	analyzers:
		phpstan: @App\Model\PhpStanAnalyzer
)

The last example is parsed differently.

Escaping

Hi There,

On a line with a string value, how would someone escape a '(' or ')'?

MyString: This (unfortunately) won't work.

There appears to be no way to do this?

URL in array can not contain "=" character

Version: 3.2.1

Bug Description

In case of NEON:

urls:
    - https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js
    - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML
    - https://baraja.cz/css/styles.css

Is it parsed to:

Snímek obrazovky 2020-12-17 v 10 11 32

Because the second URL contains = character.

Expected Behavior & Possible Solution

I think in the context of the URL (starting with #^(https?|ftp)://#) NEON should ignore character = in the URL and keep it as a string.

Thanks!

Unexpected behavior when using unquoted date as key

Version: 3.1.1

it is ok to use keys like 2020-02 without quotes, but 2020-02-02 is a syntax error.

foo:
    2020-02: bar # ok
    2020-02-02: baz # fails

i would expect the behavior to be the same regardless of number of dashes, but maybe the first case working is this some side effect of parsing numbers in sci notation?

anyway, it would be really nice if this works : ]

What are the supported formats inside an entity

I just discovered Neon and love the way it works. Especially, I love the notion of entity.

Now, I have a question about the supported syntax inside an Entity.

I've noticed that this is OK:

entity0: Column(name=Homer, phones=[ home: 555-6528, work: 555-7334 ])

This is ok too:

entity: Column(
    name: Homer
    phones: [ home: 555-6528, work: 555-7334 ]
)

But this yields what I would deem to be an unexpected result:

entity2: Column(
    name: Homer
    phones:
        home: 555-6528
        work: 555-7334
)

In the attributes array, "home" and "work" are at the same level as "name" and "phones". I would have expected those keys to be in the "phones" key.

Also, this piece of code fails to parse:

entity2: Column(
    name: Homer
    phones:
     - 555-6528
     - 555-7334
)

Is this considered a bug? If not, is there a specification of the NEON format somewhere explaining what is ok and what is not?
Could this be considered as a possible enhancement?

RFC: Encode/Decode Data Lossless (Format-preserving Printing)

Prologue

This RFC aims to keep original NEON format and prevent data losing. It's in correlation to #51.

Picture you have really big NEON file holding big definition schema with comments. It's very hand to have this kind of definition schema, because people keep their comments there and after all this NEON file is converted to JSON.

At this time we handle it like this:

  • There is table in DB holding NEON column and JSON column.
  • Someone update NEON and both columns get updated.

So far so good.

Unless you need to apply some automatic migrations, in current situation you can't. We'd loose user comments and they are really needed.

Current API

foo.neon

# List of users
users: [1,2,3,4]
# Revision v0.0.1

test.php

$content = file_get_contents('./foo.neon');

$data = Nette\Neon\Neon::decode($content);
$data->users[] = 5;

file_put_contents('./foo.neon', Nette\Neon\Neon::encode($data));

foo.neon

users: [1,2,3,4,5]

I totally understand how this API works and it works great for encoding/decoding, but it does not prevent original content.

Proposed API

AST

I am not sure how this API should look like. Maybe it would be needed to create some kind of AST parser and understand comments properly.

AST parsers is maybe too heavy and someone would bring up simpler solution.

Context Merging

Method Neon::encode does not have any context of original file, passing original file instead of string could be the way. I am not sure.

$data = Nette\Neon\Neon::merge('./foo.neon', ['users' => [5]);
file_put_contents('./foo.neon', $data);

It's an idea of adding extra feature to NEON. Maybe someone think the same way. Thanks for a feedback.

Weird syntax introduced by array-after-key

There is no check whether next token is array-bullet, so now it allows following syntax:

foo:
bar

which is parsed as

array
    foo => bar

But more complex syntax like this one:

foo:
bar
lorem:
ipsum

is not supported. ("Unexpected 'lorem'....")

So there are two possible ways how to solve this:

  1. allow only array (to be more specific, only block array with array bullet) [possible BC break], see this commit
  2. allow everything and fix that more complex syntax

Which one do you prefer?

Will there be support for HHVM?

Currently seems to be unsupported HHVM:
Fatal error: Arrays are not allowed in class constants in /vendor/nette/neon/src/Neon/Decoder.php on line 20

Will it be improved to support HHVM?

Octal values is malformed

When I write chmod octal value, leading zero is stripped and an integer returned:

Example code:
fileMode: 0777 -> returns int(777)

In PHP (and eg. Symfony Container as well) is it intepreted as an octal value and converted to integer:
var_dump(0777); // int(511)

I hope this is not intended behaviour, may we solve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.