-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
43 lines (28 loc) · 1.03 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
<?php
use Nette\Application\Routers\Route;
// Load libraries
require __DIR__ . '/libs/autoload.php';
$configurator = new Nette\Configurator;
$configurator->setDebugMode(true);
$configurator->enableDebugger(__DIR__ . '/log');
$configurator->setTempDirectory(__DIR__ . '/temp');
$container = $configurator->createContainer();
// very simple router - NAME FROM URL - NO PRESENTER
$router = $container->getService('router');
$router[] = new Route('[<name/>]', function ($presenter) use ($container) {
$httpRequest = $container->getByType('Nette\Http\Request');
//get name from url
$path = substr($httpRequest->getUrl()->path, 1);
if (!$path) {
$path = 'welcome';
}
$filename = __DIR__ . '/templates/' . $path . '.latte';
if (!is_file($filename)) {
$filename = __DIR__ . '/templates/error.latte';
}
$template = $presenter->createTemplate()->setFile($filename);
$template->templateName = $path;
return $template;
});
// Run the application!
$container->getService('application')->run();