-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
88 lines (67 loc) · 2.28 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?
/*********************************
HOUSEKEEPING
*********************************/
session_start();
// php housekeeping
date_default_timezone_set('America/Denver');
// composer bootstrapping
require 'vendor/autoload.php';
// initialize RedBean
R::setup('sqlite:dbase.sqlite');
R::freeze(true);
// app wide utility functions and constants
define('BASE_URL', 'http://localhost/Sites/DHREM/Attend');
//define('BASE_URL', 'http://www.denverem.org/attend');
/*********************************
INITIALIZE SLIM & COMPONENTS
*********************************/
$app = new \Slim\Slim(array(
'templates.path' => 'templates',
'debug' => true
));
// prepare Twig view
$app->view(new \Slim\Views\Twig());
$app->view->parserOptions = array(
'charset' => 'utf-8',
'cache' => realpath('../templates/cache'),
'auto_reload' => true,
'strict_variables' => false,
'autoescape' => true,
'debug' => true
);
// give Twig templates access to global variables, dump() function, Slim View Extras
$twig = $app->view->getEnvironment();
$twig->addGlobal('base_url', BASE_URL);
$twig->addGlobal('session', $_SESSION);
$twig->addExtension(new \Twig_Extension_Debug());
// Model services
$app->userService = new \JV\UserService();
$app->confService = new \JV\ConfService();
$app->checkinService = new \JV\CheckinService($app->userService, $app->confService);
$app->reportService = new \JV\ReportService($app->userService, $app->confService, $app->checkinService);
$app->locationService = new \JV\LocationService();
$app->configService = new \JV\ConfigService();
// Config params
$app->configs = include('config.php');
// Auth handling
$googleClientParams = array(
'client_id' => $app->configs['google_client_id'],
'client_secret' => $app->configs['google_client_secret'],
'redirect_uri' => BASE_URL . '/login',
);
$app->auth = new \JV\Auth($app, $app->userService, $googleClientParams);
/*********************************
ROUTES
*********************************/
// Routes act as views, managing data from Model services
// include all route files
$routeFiles = (array) glob('lib/routes/*.php');
foreach($routeFiles as $routeFile) {
require_once $routeFile;
}
// TEST ROUTES
/*********************************
RUN
*********************************/
$app->run();