Code Monkey home page Code Monkey logo

env's Introduction

env's People

Contributors

enygma avatar josegonzalez avatar kiennp avatar m1 avatar ohchi avatar pinepain 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

env's Issues

Strict parsing mode

We should have a strict parsing mode for .env files, specifically around general variable assignment.

Single-quoted strings still parse variables

Ran into an interesting issue today whereby one specific environment would crash during dotenv parsing. I tracked it down to a specific line and eventually realized that one of the auto-generated salts in the .env had created a string containing ${ and }. Thus, the parser would crash as the gibberish in between the braces obviously matched no variable name.

The salt was single-quoted however, so this behavior is rather unexpected as it matches neither Bash nor PHP's parsing rules. I also noticed that despite the README having such a wide variety of examples, this edge-case is missing. Any parsing or expansion of variables should probably be disabled within single quote strings.

escaped backslash not converted to real backslash

$ cat /tmp/test.env 
TEST="namespace\\class"

$ source /tmp/test.env && echo $TEST
namespace\class  

$ php -r 'require_once "vendor/autoload.php"; echo  M1\Env\Parser::parse(file_get_contents("/tmp/test.env"))["TEST"].PHP_EOL;'
namespace\\class

expected: namespace\class

Variables context

Hi! Thanks for the decent library!

I have a use case where I need to fetch variables from outer context, e.g. I have an external source which yields a FOO_SECRET=secret and later my .env refers to it, e.g.

FOO_CREDENTIALS=${FOO_USER}:${FOO_SECRET}

Currently, a lot of methods defined as private, which prevents reuse and extension. So I'm facing with two probable cases: weaken visibility from private to protected or pass array $context = [] down to VariableParser and use it in fetchVariable() when both hasParameterExpansion() and checkVariableExists() fails.

Alternatively, I would do both at once: weaken visibility and add $context.

Do you have any suggestions on topic?

Parser chokes on line only containing spaces

I had a file that worked with other .env parsers but failed with m1/env

The issue was a blank line containing only space characters. I agree that it's not a good style but it shouldn't break the parser.

Changing visibility on Parser::doParse?

Is there any chance on changing the visibility of the doParse method in the Parser class from private to maybe just protected?

This would allow for a class extending the Parser to do fun things like set the value_parser property to something else and make the call to re-parse the configuration file.

I'm happy to make a PR for it too if that'd help...

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.