Skip to content

Commit fe151c6

Browse files
committed
Fix 'missing ENVKEY' error when ENVKEY is set in $\_SERVER or $\_ENV rather than a system environment variable
1 parent d40c386 commit fe151c6

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "envkey/envkey-php",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "Keeps environment variables automatically in sync. Protects secrets with end-to-end encryption.",
55
"keywords": [
66
"env",

composer.lock

Lines changed: 31 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdkphp-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3
1+
2.4.4

src/Fetcher.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public static function fetch(){
5757
$composerData = json_decode($composerJson, true); // Decode the JSON into an associative array
5858
$version = $composerData['version']; // Access the 'version' property
5959

60+
// Check if ENVKEY is available in $_SERVER or $_ENV and set it as an environment variable
61+
// ensures it gets passed through to envkey-source call
62+
if (isset($_SERVER['ENVKEY'])) {
63+
putenv("ENVKEY={$_SERVER['ENVKEY']}");
64+
} elseif (isset($_ENV['ENVKEY'])) {
65+
putenv("ENVKEY={$_ENV['ENVKEY']}");
66+
}
67+
6068
$cmd = self::libPath().' --json --mem-cache --client-name envkey-php --client-version '.$version;
6169
$res = rtrim(shell_exec($cmd));
6270

0 commit comments

Comments
 (0)