fx-1 / api /utils /Config.php
felix-fx's picture
Initial commit from GitHub fx-1
6711fd5 verified
Raw History Blame Contribute Delete
597 Bytes
<?php
// /api/utils/Config.php
class Config {
private static $env = [];
public static function load(string $path) {
if (!file_exists($path)) return;
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) continue;
list($name, $value) = explode('=', $line, 2);
self::$env[trim($name)] = trim($value);
}
}
public static function get(string $key, $default = null) {
return self::$env[$key] ?? getenv($key) ?: $default;
}
}