61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Bootstrap - Central configuration loader
|
|
*
|
|
* All PHP files should include this file first to set up:
|
|
* - Path constants
|
|
* - Database connection
|
|
* - Session management
|
|
* - Core functions
|
|
*
|
|
* Usage:
|
|
* <?php require_once(__DIR__ . '/../../bootstrap.php'); ?>
|
|
*
|
|
* Then use constants:
|
|
* - APP_ROOT: Root directory
|
|
* - SRC_ROOT: src/ directory
|
|
* - CONFIG_PATH: src/config/ directory
|
|
* - CLASSES_PATH: src/classes/ directory
|
|
* - COMPONENTS_PATH: components/ directory
|
|
*
|
|
* And use globals:
|
|
* - $conn: MySQLi connection
|
|
* - $db: DatabaseService instance
|
|
*/
|
|
|
|
// Define root paths - adjust based on file location
|
|
if (!defined('APP_ROOT')) {
|
|
define('APP_ROOT', dirname(__DIR__));
|
|
}
|
|
if (!defined('SRC_ROOT')) {
|
|
define('SRC_ROOT', APP_ROOT . '/src');
|
|
}
|
|
if (!defined('CONFIG_PATH')) {
|
|
define('CONFIG_PATH', SRC_ROOT . '/config');
|
|
}
|
|
if (!defined('CLASSES_PATH')) {
|
|
define('CLASSES_PATH', SRC_ROOT . '/classes');
|
|
}
|
|
if (!defined('COMPONENTS_PATH')) {
|
|
define('COMPONENTS_PATH', APP_ROOT . '/components');
|
|
}
|
|
if (!defined('ASSETS_PATH')) {
|
|
define('ASSETS_PATH', APP_ROOT . '/assets');
|
|
}
|
|
|
|
// Load environment variables
|
|
require_once(CONFIG_PATH . '/env.php');
|
|
|
|
// Load database connection
|
|
require_once(CONFIG_PATH . '/connection.php');
|
|
|
|
// Load session management
|
|
require_once(CONFIG_PATH . '/session.php');
|
|
|
|
// Load core functions
|
|
require_once(CONFIG_PATH . '/functions.php');
|
|
|
|
// Optional: Set global timezone
|
|
date_default_timezone_set($_ENV['TIMEZONE'] ?? 'Africa/Johannesburg');
|
|
?>
|