-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (29 loc) · 2.05 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
███████╗ ██╗ ██╗ ███╗ ███╗ ███████╗
██╔════╝ ██║ ██║ ████╗ ████║ ██╔════╝
███████╗ ██║ ██║ ██╔████╔██║ █████╗
╚════██║ ██║ ██║ ██║╚██╔╝██║ ██╔══╝
███████║ ███████╗ ██║ ██║ ╚═╝ ██║ ███████╗
╚══════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝
1.2.2 - https://github.com/jyoungblood/slime
*/
require __DIR__ . '/vendor/autoload.php';
\Dotenv\Dotenv::createImmutable(__DIR__)->load();
$app = \Slim\Factory\AppFactory::create();
$app->addBodyParsingMiddleware();
$GLOBALS['locals'] = [ 'year' => date('Y'), 'site_title' => isset($_ENV['SITE_TITLE']) ? $_ENV['SITE_TITLE'] : false, 'site_code' => isset($_ENV['SITE_CODE']) ? $_ENV['SITE_CODE'] : false, 'site_url' => isset($_ENV['SITE_URL']) ? $_ENV['SITE_URL'] : false ];
$GLOBALS['database'] = isset($_ENV['DB_HOST']) ? \VPHP\db::init([ 'host' => $_ENV['DB_HOST'], 'name' => $_ENV['DB_NAME'], 'user' => $_ENV['DB_USER'], 'password' => $_ENV['DB_PASSWORD'] ]) : false;
$errorMiddleware = isset($_ENV['SITE_MODE']) && $_ENV['SITE_MODE'] == 'development' ? $app->addErrorMiddleware(true, true, true) : $app->addErrorMiddleware(false, false, false);
$errorMiddleware->setErrorHandler(\Slim\Exception\HttpNotFoundException::class, function ( \Psr\Http\Message\ServerRequestInterface $request, \Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails ) {
return \Slime\render::hbs($request, new \Slim\Psr7\Response(), [
'template' => 'error',
'title' => '404 - NOT FOUND',
'data' => [
'status_code' => 404,
'error_message' => 'This page could not be found.'
]
], 404);
});
require 'controllers/index.php';
$app->run();