-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
35 lines (23 loc) · 816 Bytes
/
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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use ctrl\UserController;
require 'models/UserModel.php';
$requestUri = $_SERVER['REQUEST_URI'];
$cleanUri = strtok($requestUri, '?');
$uriSegments = explode('/', trim($cleanUri, '/'));
$controllerName = isset($uriSegments[0]) ? ucfirst($uriSegments[0]) . 'Controller' : 'AccueilController';
$action = isset($uriSegments[1]) ? $uriSegments[1] : 'accueil';
$controllerFile = "ctrl/{$controllerName}.php";
if (file_exists($controllerFile)) {
require $controllerFile;
$controller = new $controllerName();
if (method_exists($controller, $action)) {
call_user_func(array($controller, $action));
} else {
include('views/404.php');
}
} else {
include('views/accueil.php');
}