Giter Site home page Giter Site logo

phpdotenv v2 about phpdotenv HOT 7 CLOSED

vlucas avatar vlucas commented on May 2, 2024
phpdotenv v2

from phpdotenv.

Comments (7)

vlucas avatar vlucas commented on May 2, 2024

That would be fantastic if you have time now. I won't have time for about another week or so myself.

I was thinking about putting everything under the Dotenv namespace, and the primary class might be named something like Dotenv\Loader.

Code use would be something like:

$dotenv = new Dotenv\Loader();
$dotenv->load();
$dotenv->required(['DATABASE_URL', 'APP_ENV']);

from phpdotenv.

kelvinj avatar kelvinj commented on May 2, 2024

I can take a look.

Thoughts on:

  1. A fluid interface
  2. Mutable by default *
  3. Single file or break out into small components

* I've always found the default mutability odd, but I know the ruby library does it. I'd argue that it's better to know that you .env variables are loaded as expected giving you an environment in a known state.

from phpdotenv.

kelvinj avatar kelvinj commented on May 2, 2024

Re: no.2 - ruby dotenv make use of a load method, which is immutable, and an overload method, which is mutable.

Re: the name – if you name it Dotenv\Loader and then you use Dotenv, your code will then look like new Loader() which is a bit funky. I'd prefer Dotenv\Dotenv, but it's your call.

Another thing, considering the weird apache bug highlighted in #39 when using getenv() it might be an idea to encourage usage of $_ENV instead… what do you think?

from phpdotenv.

vlucas avatar vlucas commented on May 2, 2024

Using Dotenv\Dotenv is fine. Also, this project was originally inspired by the Ruby version, but I don't want to be obsessed with matching it 1:1 in all respects.

from phpdotenv.

kelvinj avatar kelvinj commented on May 2, 2024

@vlucas ok. What are your thoughts on immutability?

from phpdotenv.

bcremer avatar bcremer commented on May 2, 2024

I would like to keep a static factory method so I am not forced to use a instance variable:

\Dotenv\Dotenv::create()->load();

Or to mimic the v1. api:

\Dotenv\Dotenv::load(); // loads .env and returns instance

As of PHP 5.4 the following is also possible:

(new \Dotenv\Dotenv)->load();

from phpdotenv.

kelvinj avatar kelvinj commented on May 2, 2024

I'm almost done with an initial effort, which is more to do with testing the waters on some stuff than a proposed final solution, just to see what feels right, what feels wrong …etc.

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.