-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
34 lines (26 loc) · 944 Bytes
/
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
<?php
/**
* @author Marien Fressinaud <dev@marienfressinaud.fr>
* @license http://www.gnu.org/licenses/agpl-3.0.en.html AGPL
*/
// Setup the Minz framework
$app_path = realpath(__DIR__ . '/..');
assert($app_path !== false);
include $app_path . '/vendor/autoload.php';
\App\Configuration::load('dotenv', $app_path);
// Initialize the Application and execute the request to get a Response
try {
$application = new \App\Application();
$request = \Minz\Request::initFromGlobals();
$response = $application->run($request);
} catch (\Minz\Errors\RequestError $e) {
$response = \Minz\Response::notFound('not_found.phtml', [
'error' => $e,
]);
} catch (\Exception $e) {
$response = \Minz\Response::internalServerError('internal_server_error.phtml', [
'error' => $e,
]);
}
$is_head = strtoupper($_SERVER['REQUEST_METHOD']) === 'HEAD';
\Minz\Response::sendByHttp($response, echo_output: !$is_head);