-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
71 lines (53 loc) · 1.58 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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Autoload files using composer
require_once __DIR__ . '/vendor/autoload.php';
// Use this namespace
use Steampixel\Route;
use Steampixel\Component;
use Steampixel\Portal;
// Define a global basepath
define('BASEPATH','/');
// Define our theme
define('THEME','default');
// Add the folders where the components live
Component::addFolder('themes/'.THEME);
// Add the contents folder
Component::addFolder('contents');
// Start up the magic portal engine
Portal::init();
// Add routes
Route::add('/', function() {
Component::create('page/index')->print();
});
Route::add('/contact', function() {
Component::create('page/contact')->print();
}, ['get','post']);
Route::add('/about', function() {
Component::create('page/about')->print();
});
Route::add('/privacy', function() {
Component::create('page/privacy')->print();
});
Route::add('/imprint', function() {
Component::create('page/imprint')->print();
});
Route::add('/user/([0-9]*)/edit', function($id) {
Component::create('page/edit-user')->assign('id', $id)->print();
}, 'get');
// Add a 404 not found route
Route::pathNotFound(function($path) {
header('HTTP/1.0 404 Not Found');
Component::create('page/404')->print();
});
// Add a 405 method not allowed route
Route::methodNotAllowed(function($path, $method) {
header('HTTP/1.0 405 Method Not Allowed');
Component::create('page/error')->print();
});
// Run the router
Route::run(BASEPATH);
// Compose, print, render and copy together all the portal magic
Portal::compose();