forked from artsofte-php-course/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
31 lines (24 loc) · 770 Bytes
/
index.php
File metadata and controls
31 lines (24 loc) · 770 Bytes
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
<?php
require_once 'controllers/IndexController.php';
require_once 'controllers/HelloWorldController.php';
require_once 'core/Request.php';
require_once 'core/Response.php';
require_once 'core/Router.php';
include_once 'config/routes.php';
$router = new Router($routes);
$request = Request::createFromGlobals();
try {
$route = $router->match($request->getPath());
} catch (\InvalidArgumentException $exception) {
$route = [
'controller' => 'index',
'action' => 'index'
];
}
$controllerClassName = sprintf('%sController',
ucfirst($route['controller']));
$actionMethod = $route['action'] . 'Action';
$controller = new $controllerClassName();
/** @var Response $response */
$response = $controller->$actionMethod();
$response->send();