yxsad
This commit is contained in:
@@ -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';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user