-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.php
45 lines (31 loc) · 919 Bytes
/
bootstrap.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
<?php
use Slim\Slim;
use API\Middleware\JSON;
use API\Middleware\TokenOverBasicAuth;
ini_set("display_errors",1);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
// Init application mode
if (empty($_ENV['SLIM_MODE'])) {
$_ENV['SLIM_MODE'] = (getenv('SLIM_MODE'))
? getenv('SLIM_MODE') : 'development';
}
// Init and load configuration
$config = array();
$configFile = dirname(__FILE__) . '/config/'
. $_ENV['SLIM_MODE'] . '.php';
if (is_readable($configFile)) {
require_once $configFile;
} else {
require_once dirname(__FILE__) . '/config/default.php';
}
// Create Application
$app = new \Slim\Slim(array(
'debug' => false
));
// Parses JSON body
$app->add(new \Slim\Middleware\ContentTypes());
// JSON Middleware
$app->add(new API\Middleware\JSON('/api/v1'));
// Auth Middleware (outer)
$app->add(new API\Middleware\TokenOverBasicAuth(array('root' => '/api/v1')));