forked from slimphp/Slim-Skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
38 lines (33 loc) · 1.08 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
<?php
require '../vendor/autoload.php';
// Prepare app
$app = new \Slim\Slim(array(
'templates.path' => '../application/views',
));
// Create monolog logger and store logger in container as singleton
// (Singleton resources retrieve the same log resource definition each time)
$app->container->singleton('log', function () {
$log = new \Monolog\Logger('slim-skeleton');
$log->pushHandler(new \Monolog\Handler\StreamHandler('../logs/app.log', \Monolog\Logger::DEBUG));
return $log;
});
// Prepare view
$app->view(new \Slim\Views\Twig());
$app->view->parserOptions = array(
'charset' => 'utf-8',
'cache' => realpath('../application/views/cache'),
'auto_reload' => true,
'strict_variables' => false,
'autoescape' => true
);
$app->view->parserExtensions = array(new \Slim\Views\TwigExtension());
// Define routes
$app->get('/', function () use ($app) {
// Sample log message
$app->log->info("Slim-Skeleton '/' route");
// Render index view
$app->render('index.html');
});
// $app->get('/hello/:name', 'Greeting:sayHello');
// Run app
$app->run();