From 4b20dbd4729a7341b9b1376c1a40385764fff0cb Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sun, 21 Dec 2025 01:21:53 +0100 Subject: [PATCH] update --- config/config.php | 18 ++++++++++++++++-- public/{..htaccess => .htaccess} | 0 public/index.php | 3 ++- src/App/Config.php | 6 ++++-- 4 files changed, 22 insertions(+), 5 deletions(-) rename public/{..htaccess => .htaccess} (100%) diff --git a/config/config.php b/config/config.php index c0a9546..0fc4703 100644 --- a/config/config.php +++ b/config/config.php @@ -6,8 +6,22 @@ ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); -require_once __DIR__ . '/settings.php'; -require_once __DIR__ . '/domaindata.php'; +// Pick config set: first try root files, otherwise fall back to env dir (prod/staging/...) +$appEnvFromEnv = getenv('APP_ENV') ?: 'prod'; +$envDir = rtrim(__DIR__, '/\\') . '/' . $appEnvFromEnv; + +foreach (['settings.php', 'domaindata.php'] as $cfgFile) { + $rootPath = __DIR__ . '/' . $cfgFile; + $envPath = $envDir . '/' . $cfgFile; + + if (file_exists($rootPath)) { + require_once $rootPath; + } elseif (file_exists($envPath)) { + require_once $envPath; + } else { + throw new \RuntimeException("Missing required config file: $cfgFile (looked for $rootPath or $envPath)"); + } +} // Environment: staging|prod|local (example) diff --git a/public/..htaccess b/public/.htaccess similarity index 100% rename from public/..htaccess rename to public/.htaccess diff --git a/public/index.php b/public/index.php index 2926fea..f5ce180 100644 --- a/public/index.php +++ b/public/index.php @@ -1,7 +1,8 @@