-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
44 lines (39 loc) · 1.18 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
42
43
44
<?php
declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
//include all your model files here
require 'Model/Article.php';
require 'Model/Author.php';
//include all your controllers here
require 'Controller/HomepageController.php';
require 'Controller/ArticleController.php';
require 'Controller/AuthorController.php';
// Get the current page to load
// If nothing is specified, it will remain empty (home should be loaded)
$page = $_GET['page'] ?? null;
// Load the controller
// It will *control* the rest of the work to load the page
switch ($page) {
case 'articles-index':
// This is shorthand for:
// $articleController = new ArticleController;
// $articleController->index();
(new ArticleController())->index();
break;
case 'articles-show':
// TODO: detail page
(new ArticleController())->show();
break;
case 'authors-index':
(new AuthorController())->index();
break;
case 'authors-show':
(new AuthorController())->show();
break;
case 'home':
default:
(new HomepageController())->index();
break;
}