added env

This commit is contained in:
Hickmeister
2025-01-04 14:28:17 +00:00
parent a8676a432f
commit 0fa05b6514

15
assets/php/envLoader.php Normal file
View 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);
}
}
}
?>