68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
/// CRIMSON --- A simple PHP framework.
|
|
/// Copyright © 2024 Freya Murphy <contact@freyacat.org>
|
|
///
|
|
/// This file is part of CRIMSON.
|
|
///
|
|
/// CRIMSON is free software; you can redistribute it and/or modify it
|
|
/// under the terms of the GNU General Public License as published by
|
|
/// the Free Software Foundation; either version 3 of the License, or (at
|
|
/// your option) any later version.
|
|
///
|
|
/// CRIMSON is distributed in the hope that it will be useful, but
|
|
/// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
/// GNU General Public License for more details.
|
|
///
|
|
/// You should have received a copy of the GNU General Public License
|
|
/// along with CRIMSON. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// ============================================================= ENVIRONMENT ==
|
|
|
|
// define folder paths
|
|
define('CRIMSON_ROOT', '/opt/crimson');
|
|
define('PHP_ROOT', '/opt/site');
|
|
define('WEB_ROOT', PHP_ROOT . '/web');
|
|
define('PUBLIC_ROOT', PHP_ROOT . '/public');
|
|
|
|
// =============================================================== BOOTSTRAP ==
|
|
|
|
// load the config
|
|
@include(WEB_ROOT . '/config.php');
|
|
require(CRIMSON_ROOT . '/config.php');
|
|
|
|
// load all core files (order matters)
|
|
require(CRIMSON_ROOT . '/lib/database.php');
|
|
require(CRIMSON_ROOT . '/_base.php');
|
|
require(CRIMSON_ROOT . '/_model.php');
|
|
require(CRIMSON_ROOT . '/_controller.php');
|
|
require(CRIMSON_ROOT . '/router.php');
|
|
require(CRIMSON_ROOT . '/lib/error.php');
|
|
require(CRIMSON_ROOT . '/lib/hooks.php');
|
|
require(CRIMSON_ROOT . '/lib/lang.php');
|
|
require(CRIMSON_ROOT . '/lib/meta.php');
|
|
require(CRIMSON_ROOT . '/lib/html.php');
|
|
|
|
// autoload requested directories
|
|
foreach (CONFIG['autoload'] as $dir)
|
|
foreach (glob(WEB_ROOT . $dir . '/*.php') as $file)
|
|
require($file);
|
|
|
|
// load file stamps on production
|
|
if (ENVIRONMENT == 'production')
|
|
require('/var/run/crimson/stamp.php');
|
|
|
|
// =================================================================== START ==
|
|
|
|
try {
|
|
CRIMSON_HOOK('init');
|
|
(new Router())->handle_req();
|
|
} catch (Error $e) {
|
|
CRIMSON_error_handler(
|
|
CRIMSON_E_FATAL_ERROR,
|
|
$e->getMessage(),
|
|
$e->getFile(),
|
|
$e->getLine(),
|
|
$e->getTrace(),
|
|
);
|
|
}
|