-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
59 lines (48 loc) · 1.79 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
<?php
session_start ();
date_default_timezone_set ('Asia/Jakarta');
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){
// if run on windows machine
setlocale(LC_MONETARY, 'Indonesian');
setlocale(LC_TIME, "Indonesian");
}else{
// if run on other than windows machine
setlocale(LC_MONETARY, 'id_ID');
setlocale(LC_TIME, "id_ID");
}
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
$settings = require 'app/settings.php';
$app = new \Slim\App($settings);
$app->add (new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware);
$app->add (new \Slim\Middleware\Session([
'name' => 'dummy_session',
'autorefresh' => true,
'lifetime' => '12 hour'
]));
$container = $app->getContainer ();
require 'app/container.php';
require 'app/main.php';
$app->add (new \ryan\main($container));
spl_autoload_register (function ($classname) {
$parts = explode ('\\', $classname);
$classes = "app/models/" . end ($parts);
if (file_exists ($classes . '.php')) {
require $classes . '.php';
}
});
spl_autoload_register (function ($classname) {
$parts = explode ('\\', $classname);
$classes = "app/controllers/" . end ($parts);
if (file_exists ($classes . '.php')) {
require $classes . '.php';
}
});
require 'app/template_helper.php';
$container->view->loadExtension(new \ryan\template_helper($container));
require 'app/route.php';
// $app->get ('/', function ($req, $res, $args) {
// return $res->withStatus (302)->withHeader ('Location', $this->router->pathFor ('loginPage'));
// });
$app->run ();