-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
67 lines (49 loc) · 1.49 KB
/
index.php
File metadata and controls
67 lines (49 loc) · 1.49 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
60
61
62
63
64
65
66
67
<?php
// Header
include('/assets/partials/header.html');
// In case one is using PHP 5.4's built-in server
$filename = __DIR__ . preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
return false;
}
// Include the Router class
require_once __DIR__ . '/assets/includes/Router.php';
// Create a Router
$router = new \Bramus\Router\Router();
// Custom 404 Handler
$router->set404(function () {
include ('404.php');
});
// Static route: / (homepage)
$router->get('/', function () {
include ('home.php');
});
// Static route: / (about)
$router->get('/about', function () {
require('/assets/includes/config.php');
include ('about.php');
});
// Static route: / (contact)
$router->get('/contact', function () {
require('/assets/includes/config.php');
include ('contact.php');
});
// Static route: / (thank you)
$router->get('/thank-you', function () {
include ('thank-you.php');
});
// Static route: /projects
$router->get('/projects', function () {
require('/assets/includes/config.php');
include('list.php');
});
// Dynamic route: /projects/project-name
$router->get('/projects/([a-z0-9_-]+)', function ($name) {
require('/assets/includes/config.php');
include ('detail.php');
});
// Run Router
$router->run();
// Footer
include('/assets/partials/footer.html');
?>