added env
This commit is contained in:
15
assets/php/envLoader.php
Normal file
15
assets/php/envLoader.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
function loadEnv($path) {
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
throw new Exception('.env file not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
if (strpos($line, '=') !== false) {
|
||||||
|
list($key, $value) = explode('=', $line, 2);
|
||||||
|
$_ENV[$key] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user