<?php

declare(strict_types=1);

define('ROOT_PATH', dirname(__DIR__));
define('APP_PATH', __DIR__);
define('DATA_PATH', ROOT_PATH . '/data');
define('STORAGE_PATH', ROOT_PATH . '/storage');
define('PUBLIC_PATH', ROOT_PATH . '/public');

// Config laden — ohne config.php läuft die Seite mit der Vorlage weiter (Mailversand schlägt dann fehl).
$configFile = ROOT_PATH . '/config/config.php';
$GLOBALS['__config'] = require (is_file($configFile) ? $configFile : ROOT_PATH . '/config/config.example.php');

error_reporting(E_ALL);
ini_set('display_errors', ($GLOBALS['__config']['env'] ?? 'production') === 'development' ? '1' : '0');
ini_set('log_errors', '1');
ini_set('error_log', STORAGE_PATH . '/logs/php-errors.log');

require APP_PATH . '/helpers.php';

if (is_file(ROOT_PATH . '/vendor/autoload.php')) {
    require ROOT_PATH . '/vendor/autoload.php';
}
