Files
musadaq-saas/app/bootstrap/init.php
2026-05-03 20:45:16 +03:00

46 lines
1.1 KiB
PHP

<?php
/**
* Simple Bootstrap Initialization
*/
declare(strict_types=1);
// 1. Constants
define('ROOT_PATH', dirname(__DIR__, 2));
define('APP_PATH', ROOT_PATH . '/app');
define('STORAGE_PATH', ROOT_PATH . '/storage');
// 2. Load Environment Variables
require_once APP_PATH . '/bootstrap/env.php';
// 3. Common Helpers
require_once APP_PATH . '/helpers/helpers.php';
// 4. Core Classes (Manual autoload for simplicity)
spl_autoload_register(function ($class) {
$prefix = 'App\\';
$base_dir = APP_PATH . '/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) return;
$relative_class = substr($class, $len);
// Normalize path to lowercase for directories, keep filename case
$parts = explode('\\', $relative_class);
$filename = array_pop($parts) . '.php';
$dir = strtolower(implode('/', $parts));
$file = $base_dir . ($dir ? $dir . '/' : '') . $filename;
if (file_exists($file)) {
require $file;
}
});
// 5. Response Utility
require_once APP_PATH . '/bootstrap/response.php';
// 6. Auth Session/State (Simple)
require_once APP_PATH . '/bootstrap/auth.php';