Skip to content
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

Add support for Dotenv v3, v4, and v5 #25

Merged
merged 1 commit into from
Feb 3, 2021

Conversation

mcaskill
Copy link
Contributor

Checklist:

  • I've read the Contributing page.
  • I've created an issue and referenced it here.
  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

Description

Adds support for Dotenv v5 while also keeping support for v4 and restoring support for v3.

This allows older projects that might be stuck on an older version of Dotenv to continue to benefit from updates to this Composer plugin.

How has this been tested?

I'm testing this on a client project that uses Advanced Custom Fields Pro, Gravity Forms, and Polylang Pro.

Types of changes

Added

  • Method Installer::loadDotenv() to resolve and instantiate the currently available version of the Dotenv class.
  • Class AbstractPlugin as basis for all supported WP plugins. The class provides a get() method which serves as a wrapper of getenv() that will throw an exception if the requested environment variable is missing.
  • Class MissingEnvException in case an environment variable is missing.

Changed

  • WP plugin classes to extend new AbstractPlugin and use its get() method instead of directly using getenv() function.

@junaidbhura
Copy link
Owner

Thanks @mcaskill ! As always, much appreciated!

Let me take a deeper look and get back to you!

Installer.php Outdated Show resolved Hide resolved
@junaidbhura
Copy link
Owner

junaidbhura commented Jan 17, 2021

Hey @mcaskill can we limit this PR to just the changes in Installer.php and composer.json?

I'm looking to do a big refactor of this plugin in the coming months, which will implement an Abstract class, etc.

Added:
- Support for Dotenv v3, v4, or v5.
- Method `Installer::loadDotenv()` to resolve the current version and instantiate the available `Dotenv` class.
@mcaskill
Copy link
Contributor Author

Sorry for the delay and thanks for the feedback.

@junaidbhura junaidbhura merged commit ea74d5f into junaidbhura:master Feb 3, 2021
@junaidbhura
Copy link
Owner

Thanks @mcaskill really appreciate it as always 👍

@mcaskill mcaskill deleted the feature/multi-dotenv branch February 3, 2021 13:05
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.

2 participants