Enhance configuration management: Updated README.md with Windows sync instructions, refactored backend configuration files to improve loading logic, and ensured consistent function definitions. Improved error handling in bootstrap.php for better user feedback during application startup.
This commit is contained in:
@@ -1,39 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* HexaHost – Bootstrap für Monorepo- und Produktions-Layout
|
||||
* HexaHost – Bootstrap (gleiches Prinzip wie dev-Branch: backend/ zuerst)
|
||||
*
|
||||
* Monorepo: public/../backend/{includes,config}
|
||||
* Produktion: public/{includes,config} (nach Backend-Kopie)
|
||||
* Priorität (wie Deploy auf dev.hexahost.de):
|
||||
* 1. ../backend/{includes,config} – Monorepo / Dev-Server
|
||||
* 2. public/{includes,config} – Prod nur mit Webroot public/
|
||||
* 3. Hybrid (includes/config gemischt)
|
||||
*/
|
||||
|
||||
if (!defined('HEXAHOST_BOOTSTRAPPED')) {
|
||||
$pathCandidates = [
|
||||
[
|
||||
'includes' => __DIR__ . '/includes',
|
||||
'config' => __DIR__ . '/config',
|
||||
],
|
||||
[
|
||||
'includes' => __DIR__ . '/../backend/includes',
|
||||
'config' => __DIR__ . '/../backend/config',
|
||||
],
|
||||
];
|
||||
function hexahost_path_candidates(): array
|
||||
{
|
||||
$backendIncludes = dirname(__DIR__) . '/backend/includes';
|
||||
$backendConfig = dirname(__DIR__) . '/backend/config';
|
||||
$publicIncludes = __DIR__ . '/includes';
|
||||
$publicConfig = __DIR__ . '/config';
|
||||
|
||||
return [
|
||||
['includes' => $backendIncludes, 'config' => $backendConfig],
|
||||
['includes' => $publicIncludes, 'config' => $publicConfig],
|
||||
['includes' => $publicIncludes, 'config' => $backendConfig],
|
||||
['includes' => $backendIncludes, 'config' => $publicConfig],
|
||||
];
|
||||
}
|
||||
|
||||
function hexahost_is_app_root_valid(string $includesDir, string $configDir): bool
|
||||
{
|
||||
$required = [
|
||||
$includesDir . '/functions.php',
|
||||
$includesDir . '/header.php',
|
||||
$includesDir . '/footer.php',
|
||||
$configDir . '/products-config.php',
|
||||
];
|
||||
|
||||
foreach ($required as $file) {
|
||||
if (!is_file($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$resolved = false;
|
||||
|
||||
foreach ($pathCandidates as $paths) {
|
||||
if (is_file($paths['includes'] . '/functions.php')) {
|
||||
define('HEXAHOST_INCLUDES_DIR', $paths['includes']);
|
||||
define('HEXAHOST_CONFIG_DIR', $paths['config']);
|
||||
require_once $paths['includes'] . '/functions.php';
|
||||
$resolved = true;
|
||||
break;
|
||||
foreach (hexahost_path_candidates() as $paths) {
|
||||
if (!hexahost_is_app_root_valid($paths['includes'], $paths['config'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
define('HEXAHOST_INCLUDES_DIR', $paths['includes']);
|
||||
define('HEXAHOST_CONFIG_DIR', $paths['config']);
|
||||
require_once $paths['includes'] . '/functions.php';
|
||||
$resolved = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$resolved) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'HexaHost: Anwendung konnte nicht gestartet werden (includes nicht gefunden).';
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo '<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><title>HexaHost</title></head><body>';
|
||||
echo '<h1>HexaHost: Seite konnte nicht geladen werden</h1>';
|
||||
echo '<p>PHP konnte die Anwendungsdateien nicht finden.</p>';
|
||||
echo '<p><strong>Dev-Branch:</strong> Repository mit Ordner <code>backend/</code> neben <code>public/</code> deployen.</p>';
|
||||
echo '<p><strong>Produktion:</strong> Vor dem Upload <code>scripts/sync-backend-to-public.ps1</code> ausführen ';
|
||||
echo 'oder <code>backend/includes</code> und <code>backend/config</code> nach <code>public/</code> kopieren.</p>';
|
||||
echo '</body></html>';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user