Fassung 1.7.0: verlässliche Installation, übersichtliche Verwaltung und bedienbare Bewegung
CMS quality / php (8.2) (push) Canceled after 0s
CMS quality / php (8.4) (push) Canceled after 0s
CMS quality / browser (push) Canceled after 0s
CMS quality / mysql (push) Canceled after 0s

This commit is contained in:
kantarci committed 2026-09-14 10:49:54 +02:00
1 parent b164c4edfe
commit 495b26896e
55 files changed
+1632 -423

No files matched your search

+15 -16
View File
@@ -1,29 +1,28 @@
<?php
use App\Ops\Environment;
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
// PHP web hosts may omit E from variables_order. Honor real process configuration.
foreach (['APP_ENV', 'APP_DEBUG', 'APP_SECRET', 'DATABASE_URL', 'SITE_ORIGIN', 'MEDIA_DIRECTORY'] as $name) {
$root = dirname(__DIR__);
Environment::prepare($root);
// Server variables are explicit deployment overrides; other .env.* files are never loaded.
$keys = array_keys((new Dotenv())->parse((string) file_get_contents($root.'/.env')));
foreach (array_unique([...$keys, 'APP_ENV', 'APP_DEBUG', 'APP_SECRET', 'DATABASE_URL', 'SITE_ORIGIN', 'MEDIA_DIRECTORY', 'ADMIN_PATH', 'FONT_DIRECTORY', 'ASSET_DIRECTORY']) as $name) {
$value = getenv($name, true);
if (false !== $value && !isset($_SERVER[$name]) && !isset($_ENV[$name])) {
$_SERVER[$name] = $_ENV[$name] = $value;
}
}
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
// A freshly unpacked installation has no secret, and without one nothing boots - not even the
// installer that would explain why. So the first request writes one into .env.local and never
// touches it again. If the project directory is not writable, the request still works, but only
// this one: the installer's system check says so in a sentence instead of leaving a white page.
if (!isset($_SERVER['APP_SECRET']) || '' === $_SERVER['APP_SECRET']) {
$secret = bin2hex(random_bytes(32));
$file = dirname(__DIR__).'/.env.local';
$existing = is_file($file) ? (string) file_get_contents($file) : '';
if (false === @file_put_contents($file, $existing.(str_ends_with($existing, "\n") || '' === $existing ? '' : "\n").'APP_SECRET="'.$secret.'"'."\n")) {
$secret .= '-nicht-gespeichert';
} else {
@chmod($file, 0o600);
(new Dotenv())->load($root.'/.env');
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?? 'prod';
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? '0';
if ('' === ($_SERVER['APP_SECRET'] ?? '')) {
try {
$secret = Environment::ensureSecret($root);
} catch (RuntimeException) {
// Keep the installer reachable: its system check names the missing permission.
$secret = bin2hex(random_bytes(32)).'-nicht-gespeichert';
}
$_SERVER['APP_SECRET'] = $_ENV['APP_SECRET'] = $secret;
}