-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
57 lines (39 loc) · 1.32 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
<?php
session_start();
/**
* Step 1: Require the Slim Framework using Composer's autoloader
*
* If you are not using Composer, you need to load Slim Framework with your own
* PSR-4 autoloader.
*/
define('DIR_ROOT', __DIR__);
require DIR_ROOT.'/KSL/config.php';
require DIR_ROOT.'/KSL/vendor/autoload.php';
use \Illuminate\Database\Connection;
use \KSL\Models;
use \KSL\Controllers;
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($config['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
/**
* Step 2: Instantiate a Slim application
*
* This example instantiates a Slim application using
* its default settings. However, you will usually configure
* your Slim application now by passing an associative array
* of setting names and values into the application constructor.
*/
$app = new Slim\App(['settings' => $config]);
$container = $app->getContainer();
// DB Connection
// TODO:
// This shouldn't be needed as models have their own pointer to db instance
// Right now, only controllers are using this, but all db logic should be moved
// from controllers to models
$container['connection'] = function($c) use ($capsule) {
return $capsule->getConnection();
};
$container['twig'] = \KSL\Templates::getTwig($app->getContainer());
\KSL\Routes::set($app);
$app->run();