update
This commit is contained in:
@@ -6,20 +6,14 @@ ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// 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 (['domaindata.php','settings.php'] as $cfgFile) {
|
||||
// Required config files live in /config (sync copies staging/prod here)
|
||||
foreach (['domaindata.php', 'settings.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)");
|
||||
throw new \RuntimeException("Missing required config file: $cfgFile (expected $rootPath)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,9 @@ spl_autoload_register(function ($class) {
|
||||
// 2. Funktionen laden
|
||||
require_once __DIR__ . '/../src/App/functions.php';
|
||||
|
||||
// 3. Konfiguration laden
|
||||
// Wir simulieren hier den Sync-Prozess: Wenn config/db.php nicht da ist, nimm staging.
|
||||
$configFile = file_exists(__DIR__ . '/db.php') ? __DIR__ . '/db.php' : __DIR__ . '/staging/db.php';
|
||||
$settingsFile = file_exists(__DIR__ . '/settings.php') ? __DIR__ . '/settings.php' : __DIR__ . '/staging/settings.php';
|
||||
// 3. Konfiguration laden (nur Root-Dateien; Sync kopiert staging/prod hierher)
|
||||
$settingsFile = __DIR__ . '/settings.php';
|
||||
$configFile = __DIR__ . '/db.php';
|
||||
|
||||
if (file_exists($settingsFile)) {
|
||||
require_once $settingsFile;
|
||||
@@ -45,4 +44,4 @@ if (file_exists($configFile)) {
|
||||
// Globales Config Objekt erstellen
|
||||
global $appConfig;
|
||||
$dbEnabled = defined('APP_DB_ENABLED') ? APP_DB_ENABLED : true;
|
||||
$appConfig = new \App\Config($dbConfig, $dbEnabled);
|
||||
$appConfig = new \App\Config($dbConfig, $dbEnabled);
|
||||
|
||||
Reference in New Issue
Block a user