Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR]: HJSON Config Support #15696

Closed
ghost opened this issue Sep 30, 2021 · 2 comments
Closed

[NFR]: HJSON Config Support #15696

ghost opened this issue Sep 30, 2021 · 2 comments
Labels
new feature request Planned Feature or New Feature Request

Comments

@ghost
Copy link

ghost commented Sep 30, 2021

Request for HJSON (https://hjson.github.io/) in phalcon configs it supports comments and allows to write easier to read JSON configs. It can have similar functions to existing Configs in https://docs.phalcon.io/4.0/en/api/phalcon_config

HJson config example:

/* HJson Config Example 
 Created Sep. 29th, 2021 */
[
  # Phalcon Config
  phalcon: [
    // App Base URI
    baseuri: /phalcon/
    # Some Models
    models: [
      metadata: memory
    ]
  ]
]

PHP example based on docs:

use Phalcon\Config\Adapter\HJson;
$config = new HJson("path/config.hjson");
echo $config->phalcon->baseuri;
echo $config->models->metadata;

Valid HJSON File:

{
  # Comment
  // Comment
  human:   Hjson
  /* Comment */
  machine: JSON
  /* RegEx Allowed */
  RegEx: \s+
  # Multi Line Allowed
  md:
    '''
    First line.
    Second line.
      This line is indented by two spaces.
    '''
  // allow trailing commas
  list: [
    1,
    2,
  ]
}
@ghost ghost added the new feature request Planned Feature or New Feature Request label Sep 30, 2021
@niden
Copy link
Member

niden commented Oct 1, 2021

We will let the community decide on this.

My 2 cents though: why is this necessary? I can see the benefit of having such functionality but json_encode and json_decode are the two main methods used when parsing JSON and are part of PHP. To introduce HJSON one has to implement something that would allow the parsing of the file with HJSON format.

I checked GitHub and there is such a parser but it is around 1-2k lines long. To introduce such complexity into Phalcon will make this parsing slower and not faster plus it will be bloat on the framework.

/0.02 USD.

@niden
Copy link
Member

niden commented Oct 1, 2021

Closing in favor of #14608 (comment) Will revisit if the community votes for it, or in later versions.

@niden niden closed this as completed Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant