-
-
Save parzibyte/551925d10d0099b0957f0f1d356cc768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Parzibyte; | |
use Exception; | |
class Utils | |
{ | |
static function getVarFromEnvironmentVariables($key) | |
{ | |
if (defined("_ENV_CACHE")) { | |
$vars = _ENV_CACHE; | |
} else { | |
$file = "env.php"; | |
if (!file_exists($file)) { | |
throw new Exception("The environment file ($file) does not exists. Please create it"); | |
} | |
$vars = parse_ini_file($file); | |
define("_ENV_CACHE", $vars); | |
} | |
if (isset($vars[$key])) { | |
return $vars[$key]; | |
} else { | |
throw new Exception("The specified key (" . $key . ") does not exist in the environment file"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment