-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.php
51 lines (39 loc) · 1.29 KB
/
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
46
47
48
49
50
51
<?php
require __DIR__ . '/vendor/autoload.php';
$dotenv = new \Dotenv\Dotenv(__DIR__);
$dotenv->load();
$settings['settings'] = require __DIR__ . '/src/config.php';
// Instantiate the app
$app = new \Slim\App($settings);
// DIC configuration
$container = $app->getContainer();
// View renderer
$container['view'] = function ($c) {
$settings = $c->get('settings')['renderer'];
return new Slim\Views\PhpRenderer($settings['template_path']);
};
// Monolog
$container['logger'] = function ($c) {
$settings = $c->get('settings')['logger'];
$logger = new Monolog\Logger($settings['name']);
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
return $logger;
};
// Eloquent
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($settings['settings']['db']);
$capsule->bootEloquent();
$capsule->setAsGlobal();
// Routes
$urls = require __DIR__ . '/src/routes.php';
foreach ($urls as $url) {
$app->{ $url['0'] }($url[1], '\App\Controllers\\' . $url[2]);
}
// Documentation
$app->get('/docs', function ($request, $response, $args) use ($urls) {
return $this->view->render($response, 'docs.phtml', [
'urls' => $urls,
]);
});
$app->run();