-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.php
68 lines (58 loc) · 1.82 KB
/
app.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
<?php
if(getenv("ENVIRONMENT") == "DEV") ini_set('display_errors', 1);
require_once '../vendor/autoload.php';
require_once "includes/api.php";
require_once "includes/app.storage.php";
require_once "includes/dreamspark.php";
session_cache_limiter(false);
session_start();
$app = new \Slim\Slim([
'view' => new \Slim\Views\Twig(),
'templates.path' => './views'
]);
$view = $app->view();
$view->parserOptions = [
'debug' => true,
'cache' => dirname(__FILE__) . '/assets/cache/twig'
];
// Set the template directories for Twig
$viewPath = 'views';
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($viewPath, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
$paths = [$viewPath];
foreach ($iter as $path => $dir) {
if ($dir->isDir()) {
$paths[] = $path;
}
}
$view->twigTemplateDirs = $paths;
$view->parserExtensions = array(
new \Slim\Views\TwigExtension(),
);
if(getenv("ENVIRONMENT") != "DEV") {
// Disable public debug logs
$app->config('debug', false);
// Disable view debug logs
$view->parserOptions['debug'] = false;
// Load assets from cache
$view->appendData([
'cache' => json_decode(file_get_contents('assets/cache/cache.json'))
]);
}
appStorage::connect();
$app->OAuth2 = new stdClass();
$app->OAuth2->provider = new TheNetworg\OAuth2\Client\Provider\Azure([
'clientId' => getenv("Auth_appId"),
'clientSecret' => getenv("Auth_appSecret"),
'redirectUri' => getenv("Auth_redirectUri")
]);
require_once "includes/app.errors.php";
require_once "includes/app.oauth2.php";
require_once "includes/app.router.php";
require_once "includes/app.applicationinsights.php";
\Slim\ApplicationInsights::init();
$app->run();
?>