-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
67 lines (56 loc) · 1.63 KB
/
index.php
File metadata and controls
67 lines (56 loc) · 1.63 KB
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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
/**
* Prettify debugging message using print_r
*
* @param mixed $a
* @return void
*/
function debug_r($a = null) {
echo '<pre>';
print_r($a);
echo '</pre>';
}
/**
* Prettify debugging message using var_dump
*
* @param mixed $a
* @return void
*/
function debug_dump($a = null) {
echo '<pre>';
var_dump($a);
echo '</pre>';
}
// Define appropriate directory separator base on the current OS
PHP_OS == "Windows" || PHP_OS == "WINNT" ? define("SEPARATOR", "\\") : define("SEPARATOR", "/");
require_once __DIR__ . SEPARATOR . 'vendor' . SEPARATOR . 'autoload.php';
require_once __DIR__ . SEPARATOR . 'config' . SEPARATOR . 'config.php';
// Initialize $klein object
$klein = new \Klein\Klein();
// Register Session
$sessionFactory = new \Aura\Session\SessionFactory();
$session = $sessionFactory->newInstance($_COOKIE);
$segment = $session->getSegment('Generator');
$klein->service()
->sharedData()
->set('session', $segment);
// Register the routes
$klein->with(CONFIG_URI, function() use ($klein) {
// Handling HTTP errors, e.g. 404, 405
$klein->onHttpError(function ($code, $router) {
switch ($code) {
case 404:
case 405:
default:
$router->response()
->redirect(CONFIG_URI . '/page-not-found');
}
});
// Register routes
// Adding of routes will be in this file
require_once __DIR__ . SEPARATOR . 'config' . SEPARATOR . 'routes.php';
});
// Serve the pages
$klein->dispatch();