-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
28 lines (22 loc) · 758 Bytes
/
index.php
File metadata and controls
28 lines (22 loc) · 758 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
<?php
define('BASEPATH', "WebForce3/PHPMVC/Exemples");
require_once __DIR__ . "/vendor/autoload.php";
spl_autoload_register(function($className){
$className = 'src/' . $className .'.php';
if (file_exists($className)) {
require_once($className);
}
});
// Init twig
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/src/View');
$twig = new \Twig\Environment($loader, [
'cache' => __DIR__ . '/src/cache',
'debug' => true
]);
$twig->addGlobal('path', BASEPATH);
use Controller\FrontController;
$frontController = new FrontController();
$frontController->setBasePath(BASEPATH);
$templateInfos = $frontController->run();
$template = $twig->load($templateInfos['template']);
echo $template->render($templateInfos['data']);