53 lines
1.3 KiB
PHP
Executable File
53 lines
1.3 KiB
PHP
Executable File
<?php
|
|
declare(strict_types=1);
|
|
|
|
// 1. Autoloader für App Namespace
|
|
spl_autoload_register(function ($class) {
|
|
$prefix = 'App\\';
|
|
$base_dir = __DIR__ . '/../src/App/';
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
$relative_class = substr($class, $len);
|
|
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
|
|
|
if (file_exists($file)) {
|
|
require $file;
|
|
}
|
|
});
|
|
|
|
// 2. Funktionen laden
|
|
require_once __DIR__ . '/../src/App/functions.php';
|
|
|
|
// 3. Konfiguration laden (nur Root-Dateien; Sync kopiert staging/prod hierher)
|
|
$domainFile = __DIR__ . '/domaindata.php';
|
|
$settingsFile = __DIR__ . '/settings.php';
|
|
$configFile = __DIR__ . '/db.php';
|
|
|
|
if (file_exists($domainFile)) {
|
|
require_once $domainFile;
|
|
}
|
|
|
|
if (file_exists($settingsFile)) {
|
|
require_once $settingsFile;
|
|
}
|
|
|
|
$dbConfig = [];
|
|
if (file_exists($configFile)) {
|
|
$dbConfig = require $configFile;
|
|
}
|
|
|
|
// Globales Config Objekt erstellen
|
|
global $appConfig;
|
|
$dbEnabled = defined('APP_DB_ENABLED') ? APP_DB_ENABLED : true;
|
|
$appConfig = new \App\Config($dbConfig, $dbEnabled);
|