Last active
August 11, 2020 08:31
-
-
Save evaisse/00b1e376f33d52edebda8e39428d8b03 to your computer and use it in GitHub Desktop.
A simple dotenv (.env) file parsing function to avoid dependencies
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 | |
function read_dotenv(string $filePath) { | |
$envs = parse_ini_file($filePath); | |
foreach ($envs as $k => $v) { | |
$k = strtoupper($k); | |
putenv("$k=$v"); | |
$_ENV[$k] = $_SERVER[$k] = $v; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment