Skip to content

Allow getenv() to work again with vlucas/phpdotenv 5.x #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2020

Conversation

joelpittet
Copy link
Contributor

https://github.com/vlucas/phpdotenv no longer works with getenv() by default in 5.x, you need to call explicitly Dotenv::createUnsafeImmutable to have those calls work. There are may places that use getenv() calls still including Drush.

-$dotenv = Dotenv::createImmutable(__DIR__);
+$dotenv = Dotenv::createUnsafeImmutable(__DIR__);

@webflo
Copy link
Member

webflo commented Dec 4, 2020

@joelpittet Using createImmutable is the recommend ways to use library and we updated our examples in this repo accordingly. 2d48c40

Could you try to update your project? I would review a PR to change the code in Drush.

@webflo webflo merged commit eeea242 into drupal-composer:9.x Dec 11, 2020
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
$dotenv = Dotenv::createUnsafeImmutable(__DIR__);
$dotenv->load();
Copy link
Collaborator

@normanlolx normanlolx Dec 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you switched safeLoad for load here? Drush site install now fails when there's no .env file around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just the docs indicating load() is the way to do it. I think I need a PR for Drush too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the method and yeah thanks for keeping it safeLoad()

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