-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
139 lines (104 loc) · 4.25 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* @license MIT
* cinetech (muvisho)
* Copyright (c) 2023 Abraham Ukachi. The Muvisho Project Contributors.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @project cinetech
* @name Main / Router - Muvisho
* @file index.php
* @author: Abraham Ukachi <abraham.ukachi@laplateforme.io>
* @version: 0.0.1
*
* Usage:
* 1+|> // how-to route with AltoRouter ;)
* -|>
*
*/
/*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* MOTTO: I'll always do more 😜 !!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
// ---===--- enabling error reporting ---====---
error_reporting(E_ALL);
ini_set("display_errors", 1);
// ---===---===---===---===---===---===---===---
// require the autoloader
require __DIR__ . '/../vendor/autoload.php';
// start the session
session_start();
// defining some constants...
const APP_NAME = 'cinetech';
// home or base directory of Muvisho
const MUVISHO_HOME_DIR = '/' . APP_NAME;
// define some paths
const PUBLIC_PATH = 'root/public';
const ASSETS_PATH = PUBLIC_PATH . '/assets';
const IMAGES_PATH = ASSETS_PATH . '/images';
const ANIMATIONS_PATH = ASSETS_PATH . '/animations';
const FONTS_PATH = ASSETS_PATH . '/fonts';
const LOCALE_PATH = ASSETS_PATH . '/locale';
const LOGOS_PATH = ASSETS_PATH . '/logos';
const THEME_PATH = ASSETS_PATH . '/theme';
const STYLESHEETS_PATH = ASSETS_PATH . '/stylesheets';
// define other directory constants
// muvisho
const __MUVISHO_DIR__ = __DIR__ . '/../../root';
const __MUVISHO_ROUTES_DIR__ = __MUVISHO_DIR__ . '/routes';
const __MUVISHO_DATABASE_DIR__ = __MUVISHO_DIR__ . '/database';
const __MUVISHO_CONFIG_DIR__ = __MUVISHO_DIR__ . '/config';
const __MUVISHO_TESTS_DIR__ = __MUVISHO_DIR__ . '/tests';
// ++++ public - assets ++++
const __MUVISHO_PUBLIC_DIR__ = __DIR__ . '/../public';
const __MUVISHO_ASSETS_DIR__ = __MUVISHO_PUBLIC_DIR__ . '/assets';
const __MUVISHO_IMAGES_DIR__ = __MUVISHO_ASSETS_DIR__ . '/images';
const __MUVISHO_ANIMATIONS_DIR__ = __MUVISHO_ASSETS_DIR__ . '/animations';
const __MUVISHO_FONTS_DIR__ = __MUVISHO_ASSETS_DIR__ . '/fonts';
const __MUVISHO_LOCALE_DIR__ = __MUVISHO_ASSETS_DIR__ . '/locale';
const __MUVISHO_LOGOS_DIR__ = __MUVISHO_ASSETS_DIR__ . '/logos';
const __MUVISHO_THEME_DIR__ = __MUVISHO_ASSETS_DIR__ . '/theme';
const __MUVISHO_STYLESHEETS_DIR__ = __MUVISHO_ASSETS_DIR__ . '/stylesheets';
// ++++ end of public - assets ++++
// app
const __APP_DIR__ = __DIR__ . '/../../app';
const __APP_MODELS_DIR__ = __DIR__ . '/../../app/Models';
const __APP_VIEWS_DIR__ = __DIR__ . '/../../app/Views';
const __APP_CONTROLLERS_DIR__ = __DIR__ . '/../../app/Controllers';
// Create an altorouter instance named `$router`
$router = new AltoRouter();
// Set the base path of the router
$router->setBasePath(MUVISHO_HOME_DIR);
// Now, let's add some routes to our router ;)
// Include the App and API routes
include __DIR__ . '/../routes/app-routes.php'; // <- app routes
include __DIR__ . '/../routes/api-routes.php'; // <- api routes
// match the current request url
$match = $router->match();
// call closure or throw 404 status
if(is_array($match) && is_callable($match['target'])) {
call_user_func_array($match['target'], $match['params']);
} else {
// TODO: Create a 404 view / page to handle this
// no route was matched
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}