/
index.php
67 lines (50 loc) · 1.65 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require 'vendor/autoload.php';
$templatesPath = dirname(__FILE__) . '/templates';
$config = [
'debug' => true,
'mode' => 'development',
'view' => new \Slim\Views\Twig(),
'templates.path' => $templatesPath,
];
$app = new \Slim\Slim($config);
$view = $app->view();
/** Whoops errors **/
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware);
/* -- */
/** Debug Bar **/
use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
$debugbar->addCollector(new DebugBar\Bridge\SlimCollector($app));
$loader = new Twig_Loader_Filesystem('.');
$env = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader));
$debugbar->addCollector(new DebugBar\Bridge\Twig\TwigCollector($env));
$debugbarRenderer = $debugbar->getJavascriptRenderer();
$view->appendData(['debugbarRenderer' => $debugbarRenderer]);
/* -- */
$view->parserOptions['debug'] = true;
$view->parserExtensions = array(
new \Slim\Views\TwigExtension(),
new \Twig_Extension_Debug()
);
/*$app->get('/', function() use($app) {
$app->render('index.twig');
});*/
$app->get('/', function() use($app) {
$em = new \App\EntityManager('news');
$news = $em->findAll();
$app->render('index.twig', compact('news'));
})->name('home');
/** Inject variable into twig **/
$folders = App\App::getFolders();
$view->appendData(['navigation' => $folders]);
$router = new App\ConfigManager();
$view->appendData(['router' => $router]);
/** ---- **/
require "routes.php";
/** Inject variable into twig **/
$site = App\App::getConfig('site');
$view->appendData(['site' => $site]);
/** ---- **/
//$app->get('/emix/:article', 'App\AppController:test')->name('news.show');
$app->run();