-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.php
executable file
·80 lines (63 loc) · 1.99 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
<?php
/**
* @Entry
* @Surface Framework
* @Author: Vinay Khobragade
* @Contact me: [email protected]
* @Github: github.com/feat7
*/
use \app\config\Config;
use Illuminate\Database\Capsule\Manager as Capsule;
if(!file_exists(__DIR__ . "/env.config.php")){
exit("Environment file not found. Please coyp env.config.example.php to env.config.php or see the documentation for more details");
}
require_once 'env.config.php';
if(APP_MODE == '__DEV__')
ini_set('display_errors', 'on'); //Just for development mode
session_start(); //The game begins
/**
* @Implementing Autoloader with two base namespaces.
*/
$loader = require 'vendor/autoload.php';
$loader->add('system', __DIR__);
$loader->add('app', __DIR__);
/**
* @Let us eat a capsule to use eloquent
*/
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'mysql',
'host' => DB_HOST,
'database' => DB_NAME,
'username' => DB_USER,
'password' => DB_PASS,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Set the event dispatcher used by Eloquent models... (optional)
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));
// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();
// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent(); //eloquent boot done
$kernel = new system\Kernel(); //boot kernel
/**
* @function view
* @param view: string | path to view template
* @param vars: array | inject variabes into view template
*/
function view($view, $vars = [])
{
$twigLoader = new Twig_Loader_Filesystem('./app/views');
$twig = new Twig_Environment($twigLoader, array(
'cache' => './app/cache',
'auto_reload' => true,
'debug' => true
));
$twig->addExtension(new Twig_Extension_Debug());
$template = $twig->loadTemplate($view);
echo $template->render($vars);
}