-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
79 lines (56 loc) · 1.92 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
<?php
declare(strict_types=1);
/* Error to execeptions */
function exception_error_handler($severidad, $mensaje, $fichero, $línea)
{
if (!(error_reporting() & $severidad)) {
// Este código de error no está incluido en error_reporting
return;
}
throw new ErrorException($mensaje, 0, $severidad, $fichero, $línea);
}
set_error_handler("exception_error_handler");
/* Composer & PSR 4 */
require_once 'vendor/autoload.php';
/* Configuration Start */
\Core\ServicesContainer::setConfig(
require_once 'config.php'
);
/* Initialize DbContext */
\Core\ServicesContainer::initializeDbContext();
$config = \Core\ServicesContainer::getConfig();
/* Default Time Zone */
date_default_timezone_set($config['timezone']);
ini_set('memory_limit', '-1');
/* Base url */
$base_url = '';
$base_folder = strtolower(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']));
if (isset($_SERVER['HTTP_HOST'])) {
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://' . $_SERVER['HTTP_HOST'];
$base_url .= $base_folder;
}
define('_BASE_HTTP_', $base_url);
define('_BASE_PATH_', __DIR__ . '/');
define('_LOG_PATH_', __DIR__ . '/log/');
define('_CACHE_PATH_', __DIR__ . '/cache/');
define('_APP_PATH_', __DIR__ . '/app/');
define('_CURRENT_URI_', $_SERVER['REQUEST_URI']);//str_replace($base_folder, '', $_SERVER['REQUEST_URI']));
if ($config['environment'] === 'stop') {
exit('Sitio web temporalmente fuera de servicio..');
}
if ($config['environment'] === 'prod') {
error_reporting(0);
}
/* Configuration End */
/* Router Start */
$router = new Phroute\Phroute\RouteCollector();
require_once 'app/filters.php';
require_once 'app/routes.php';
$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());
$response = $dispatcher->dispatch(
$_SERVER['REQUEST_METHOD'],
_CURRENT_URI_
);
echo $response;
/* Router End */