Skip to content

Commit

Permalink
Fix 'missing ENVKEY' error when ENVKEY is set in $\_SERVER or $\_ENV …
Browse files Browse the repository at this point in the history
…rather than a system environment variable
  • Loading branch information
danenania committed Oct 20, 2023
1 parent d40c386 commit fe151c6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "envkey/envkey-php",
"version": "2.4.3",
"version": "2.4.4",
"description": "Keeps environment variables automatically in sync. Protects secrets with end-to-end encryption.",
"keywords": [
"env",
Expand Down
61 changes: 31 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdkphp-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3
2.4.4
8 changes: 8 additions & 0 deletions src/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public static function fetch(){
$composerData = json_decode($composerJson, true); // Decode the JSON into an associative array
$version = $composerData['version']; // Access the 'version' property

// Check if ENVKEY is available in $_SERVER or $_ENV and set it as an environment variable
// ensures it gets passed through to envkey-source call
if (isset($_SERVER['ENVKEY'])) {
putenv("ENVKEY={$_SERVER['ENVKEY']}");
} elseif (isset($_ENV['ENVKEY'])) {
putenv("ENVKEY={$_ENV['ENVKEY']}");
}

$cmd = self::libPath().' --json --mem-cache --client-name envkey-php --client-version '.$version;
$res = rtrim(shell_exec($cmd));

Expand Down

0 comments on commit fe151c6

Please sign in to comment.