Skip to content

Update .env.example to reflect latest version of vlucas/phpdotenv.#577

Merged
webflo merged 1 commit intodrupal-composer:9.xfrom
mpdonadio:bugfix/phpdotenv
Oct 23, 2020
Merged

Update .env.example to reflect latest version of vlucas/phpdotenv.#577
webflo merged 1 commit intodrupal-composer:9.xfrom
mpdonadio:bugfix/phpdotenv

Conversation

@mpdonadio
Copy link
Copy Markdown
Contributor

The latest version of vlucas/phpdotenv doesn't support getenv() in Dotenv::createImmutable(); you need to use one of the superglobals. This updates .env.example to reflect proper usage.

@weitzman
Copy link
Copy Markdown
Contributor

weitzman commented Oct 2, 2020

Thats strange. This PR is a regression at least in older php versions. See https://stackoverflow.com/a/21473853/265501

@mpdonadio
Copy link
Copy Markdown
Contributor Author

If we are targeting the drupal-9.0.x branch, then the composer.json has a min of PHP 7.3, and drupal-drupal-8.x.y is 7.0.8, so I am not sure we need to worry too much about old PHP versions.

From https://github.com/vlucas/phpdotenv/blob/master/README.md#putenv-and-getenv

Using getenv() and putenv() is strongly discouraged due to the fact that these functions are not thread safe, however it is still possible to instruct PHP dotenv to use these functions. Instead of calling Dotenv::createImmutable, one can call Dotenv::createUnsafeImmutable, which will add the PutenvAdapter behind the scenes. Your environment variables will now be available using the getenv method, as well as the super-globals:

load.environment.php uses Dotenv::createImmutable(), so I think the doc fix is the safest.

Here is a mini example of the problem, https://github.com/mpdonadio/phpdotenv-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants