-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
59 lines (40 loc) · 1.75 KB
/
index.php
File metadata and controls
59 lines (40 loc) · 1.75 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpSPA\App;
use PhpSPA\Compression\Compressor;
use PhpSPA\Core\Http\HttpRequest;
use PhpSPA\Http\Response;
chdir(__DIR__); // --- Change the current working directory to the project root dir ---
// --- Load components ---
require_once 'app/layout/layout.php';
require_once 'app/pages/HomePage.php';
require_once 'app/pages/AboutPage.php';
require_once 'app/pages/DocsPage.php';
// --- Start Application ---
$app = new App($layout);
$app->useModule();
$app->useStatic('/', __DIR__ . '/public/');
// --- Attach components to application ---
$app->attach($homePage);
$app->attach($aboutPage);
$app->attach($docsPage);
// --- Add global meta data to the application ---
$app->meta(charset: 'UTF-8')
->meta(name: 'viewport', content: 'width=device-width, initial-scale=1.0')
->link(rel: 'preconnect', content: 'https://fonts.googleapis.com')
->link(rel: 'preconnect', content: 'https://fonts.gstatic.com', attributes: ['crossorigin' => true])
->link(rel: 'stylesheet', content: 'https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap', type: 'text/css')
->link(rel: 'shortcut icon', content: '/logo.svg', type: 'image/xml+svg')
->link(rel: 'apple-touch-icon', content: '/logo.svg', type: 'image/xml+svg');
// --- For Production ---
if (getenv('APP_ENV') === 'production') {
$app->compression(Compressor::LEVEL_EXTREME);
// --- Apply Canonical Link ---
$req = new HttpRequest();
$siteURL = getenv('APP_URL') ?: $req->siteURL();
$app->link(rel: 'canonical', content: $siteURL);
}
// --- Run the application ---
$app->run();
// --- Return 404 error if no route was matched ---
Response::sendError('Page not found', Response::StatusNotFound);