Update: 2026-05-03 18:12:07

This commit is contained in:
Hamza-Ayed
2026-05-03 18:12:07 +03:00
parent 501fd96dc1
commit 0d458e8d81

View File

@@ -3,14 +3,24 @@
* Simple .env Loader * Simple .env Loader
*/ */
if (file_exists(ROOT_PATH . '/.env')) { // Primary environment file path as requested
$lines = file(ROOT_PATH . '/.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $envFile = '/home/intaleqapp-musadaq/env/.env';
// Fallback for local development if the primary server path doesn't exist
if (!file_exists($envFile)) {
$envFile = ROOT_PATH . '/.env';
}
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) { foreach ($lines as $line) {
if (str_starts_with(trim($line), '#')) continue; if (str_starts_with(trim($line), '#')) continue;
list($name, $value) = explode('=', $line, 2); $parts = explode('=', $line, 2);
$name = trim($name); if (count($parts) !== 2) continue;
$value = trim($value, " \t\n\r\0\x0B\"'");
$name = trim($parts[0]);
$value = trim($parts[1], " \t\n\r\0\x0B\"'");
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) { if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
putenv(sprintf('%s=%s', $name, $value)); putenv(sprintf('%s=%s', $name, $value));