Giter Site home page Giter Site logo

Comments (6)

motin avatar motin commented on May 1, 2024

+1

from phpdotenv.

vlucas avatar vlucas commented on May 1, 2024

I agree.

from phpdotenv.

MethodGrab avatar MethodGrab commented on May 1, 2024

Great, thanks 👍 !

from phpdotenv.

sebastiaandegeus avatar sebastiaandegeus commented on May 1, 2024

I disagree. Especially to include such a breaking change in a minor release. This could break projects which depend on an empty value being set.

See also:
#38

from phpdotenv.

motin avatar motin commented on May 1, 2024

Relevant: #35

from phpdotenv.

motin avatar motin commented on May 1, 2024

I agree with both sides :) There are pros and cons.

The generally better way to check env vars is to check for it's existance (getenv() returns false when it doesn't exist). Only env vars that have not been set, or specifially unset before execution of a script will be caught as "not set". Thus, a prerequisite for that type of check is to support unset within .env in case a env var is already defined for some reason (also see OP's example). This way, configuration directives can be set to "0", "" and other "empty" values as defined by php, without issues.

However, many will want the basic validation check to indicate that it has a non-empty, so changing it to the default behavior is not a bad idea imo. At the same time, it is not a good idea to break the api between minor versions. Maybe have two different methods? One requiredExists that requires it to be set only, and one required that requires them to be non-empty?

Btw, as soon as #35 is merged, one can manually specify "" as an allowed value for those specific config directives, so both methods could be used.

from phpdotenv.

Related Issues (20)

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.