commit
This commit is contained in:
@@ -1,41 +1,48 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// 1) Load config (constants, env, domains)
|
||||
require_once __DIR__ . '/config.php';
|
||||
// 1. Autoloader für App Namespace
|
||||
spl_autoload_register(function ($class) {
|
||||
$prefix = 'App\\';
|
||||
$base_dir = __DIR__ . '/../src/App/';
|
||||
|
||||
// 2) Composer Autoloader (falls vorhanden)
|
||||
$composerAutoload = __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists($composerAutoload)) {
|
||||
require_once $composerAutoload;
|
||||
} else {
|
||||
// 2b) Fallback: minimaler Autoloader
|
||||
spl_autoload_register(function (string $class): void {
|
||||
$prefix = 'App\\';
|
||||
if (!str_starts_with($class, $prefix)) {
|
||||
$len = strlen($prefix);
|
||||
if (strncmp($prefix, $class, $len) !== 0) {
|
||||
// Versuche Repository Namespace
|
||||
if (str_starts_with($class, 'App\\Repository\\')) {
|
||||
$base_dir = __DIR__ . '/../src/Repository/';
|
||||
$len = strlen('App\\Repository\\');
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$rel = substr($class, strlen($prefix));
|
||||
$path = __DIR__ . '/../src/App/' . str_replace('\\', '/', $rel) . '.php';
|
||||
$relative_class = substr($class, $len);
|
||||
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
||||
|
||||
if (file_exists($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
});
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
}
|
||||
});
|
||||
|
||||
// 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';
|
||||
|
||||
if (file_exists($settingsFile)) {
|
||||
require_once $settingsFile;
|
||||
}
|
||||
|
||||
// 3) Global helper functions (tpl(), t(), asset_*())
|
||||
require_once __DIR__ . '/../src/helpers.php';
|
||||
$dbConfig = [];
|
||||
if (file_exists($configFile)) {
|
||||
$dbConfig = require $configFile;
|
||||
}
|
||||
|
||||
// 4) Initialize App (services)
|
||||
$config = \App\Config::fromPhpConstants(__DIR__ . '/../config');
|
||||
\App\App::init($config);
|
||||
|
||||
// 5) Start session + create client-id cookie
|
||||
$app = \App\App::get();
|
||||
$app->session()->start();
|
||||
$clientId = $app->session()->ensureClientId();
|
||||
|
||||
// Optionally expose a single global for templates if desired
|
||||
$GLOBALS['client_id'] = $clientId;
|
||||
// Globales Config Objekt erstellen
|
||||
global $appConfig;
|
||||
$dbEnabled = defined('APP_DB_ENABLED') ? APP_DB_ENABLED : true;
|
||||
$appConfig = new \App\Config($dbConfig, $dbEnabled);
|
||||
Reference in New Issue
Block a user