Skip to content

Allow read-only mode #163

@barryvdh

Description

@barryvdh

There has been some discussion about using putenv() and setting the $_ENV/$_SERVER vars, related to security and threads, eg #76 and #124, laravel/framework#8187 and Twitter: https://twitter.com/weltling/status/700036432761659392 etc.

Those commonly revolve about setting (sensitive) data in the Environment variables. While usage in production is discouraged (through a small note in the end of the readme), it doesn't mention anything about security issues (like leaking data to other processes or turning up in dumps)

My guess is that this library is mainly used to READ files from both environment vars and the .env file, but for many cases doesn't really care about putting stuff back. So why not add a 'read only' mode:

  • Loading vars loads all data in an internal cache, instead of putting them in Env vars
  • Finding a var will use the cache as first source (eg dotenv('DB_PASS') instead of getenv('DB_PASS'))

(Similar to what @progmars suggested in #76 (comment) but also not using the putenv anymore).

This could be an optional flag, just like immutable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions