summaryrefslogtreecommitdiff
path: root/src/index.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-12-23 10:39:16 -0500
committerFreya Murphy <freya@freyacat.org>2024-12-23 10:39:16 -0500
commitde9cae795f93d03e68d965c59af4b21d96df4ec7 (patch)
treead4f903c04630b3b92e2b9b5d06d5b8647d299bb /src/index.php
parentlicense (diff)
downloadcrimson-de9cae795f93d03e68d965c59af4b21d96df4ec7.tar.gz
crimson-de9cae795f93d03e68d965c59af4b21d96df4ec7.tar.bz2
crimson-de9cae795f93d03e68d965c59af4b21d96df4ec7.zip
initial
Diffstat (limited to 'src/index.php')
-rw-r--r--src/index.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/index.php b/src/index.php
new file mode 100644
index 0000000..98b8be7
--- /dev/null
+++ b/src/index.php
@@ -0,0 +1,68 @@
+<?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(),
+ );
+}