<?php

declare(strict_types=1);

if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}

define('INSTALL_PATH', __DIR__);
define('PROJECT_PATH', dirname(__DIR__));

spl_autoload_register(
    static function (string $class): void {
        $prefix = 'Install\\';

        if (!str_starts_with($class, $prefix)) {
            return;
        }

        $relativeClass = substr($class, strlen($prefix));
        $file = INSTALL_PATH
            . DIRECTORY_SEPARATOR
            . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass)
            . '.php';

        if (is_file($file)) {
            require_once $file;
        }
    }
);

require_once INSTALL_PATH . '/config.php';
