yxsad
All checks were successful
Deploy / deploy-staging (push) Successful in 24s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-25 01:14:13 +02:00
parent 52879ede31
commit 9531fdbd35

View File

@@ -14,7 +14,7 @@ final class ConfigLoader
$basePath = $projectRoot . '/config/' . $name . '.php'; $basePath = $projectRoot . '/config/' . $name . '.php';
$config = is_file($basePath) ? require $basePath : []; $config = is_file($basePath) ? require $basePath : [];
$appEnv = getenv('APP_ENV') ?: 'local'; $appEnv = self::detectEnvironment();
$envPath = $projectRoot . '/config/' . $appEnv . '/' . $name . '.php'; $envPath = $projectRoot . '/config/' . $appEnv . '/' . $name . '.php';
if (!is_file($envPath)) { if (!is_file($envPath)) {
@@ -45,4 +45,27 @@ final class ConfigLoader
return $base; return $base;
} }
private static function detectEnvironment(): string
{
$appEnv = trim((string) getenv('APP_ENV'));
if ($appEnv !== '') {
return $appEnv;
}
$host = strtolower(trim((string) ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? '')));
if ($host === '') {
return 'local';
}
if (str_contains($host, 'staging.')) {
return 'staging';
}
if (str_contains($host, 'desktop.kusche.berlin')) {
return 'prod';
}
return 'local';
}
} }