/
index.php
114 lines (91 loc) · 3.63 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
<?php
if (file_exists('vendor/autoload.php')) {
require 'vendor/autoload.php';
} else {
echo "<h1>Please install via composer.json</h1>";
echo "<p>Install Composer instructions: <a href='https://getcomposer.org/doc/00-intro.md#globally'>https://getcomposer.org/doc/00-intro.md#globally</a></p>";
echo "<p>Once composer is installed navigate to the working directory in your terminal/command promt and enter 'composer install'</p>";
exit;
}
if (!is_readable('app/Core/Config.php')) {
die('No Config.php found, configure and rename Config.example.php to Config.php in app/Core.');
}
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but production will hide them.
*/
if (defined('ENVIRONMENT')) {
switch (ENVIRONMENT) {
case 'development':
error_reporting(E_ALL);
break;
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
//initiate config
new Core\Config();
//create alias for Router
use Core\Router;
use Helpers\Hooks;
//define routes
Router::any('rest/(:num)', 'Controllers\Rests@rest');
Router::any('rests/(:num)', 'Controllers\Rests@rest');
Router::any('mail/test', 'Controllers\Mail@test');
Router::any('rests/update/(:num)', 'Controllers\Rests@update_restaurant');
Router::any('rests/update', 'Controllers\Rests@update_restaurant');
Router::any('rests/update_all', 'Controllers\Rests@update_all');
Router::any('rests', 'Controllers\Rests@index');
Router::any('rest/(:num)/delivery_report', 'Controllers\Rests@delivery_report');
Router::any('delivery_report/(:num)', 'Controllers\Rests@delivery_report');
Router::any('delivery/(:num)', 'Controllers\Rests@delivery_report');
Router::any('dishes/parse/(:num)', 'Controllers\Rests@parse');
Router::any('dishes/parse_all', 'Controllers\Rests@parse_all');
Router::any('ping', 'Controllers\Rests@ping');
Router::any('login', 'Controllers\Auth@login');
Router::any('register', 'Controllers\Auth@register');
Router::any('logout', 'Controllers\Auth@logout');
Router::any('user/dishes', 'Controllers\User@dishes');
Router::any('user/rand_dish', 'Controllers\User@rand_dish');
Router::any('favorite/(:num)/(:num)', 'Controllers\User@manage_favorite');
Router::any('favorite/(:num)', 'Controllers\User@manage_favorite');
Router::any('search', 'Controllers\Search@search_post');
Router::any('search/(:any)', 'Controllers\Search@search');
Router::any('advanced_search', 'Controllers\Search@advanced_search');
Router::any('json/search', 'Controllers\Json@search');
Router::any('json/all_dishes', 'Controllers\Json@all_dishes');
Router::any('', 'Controllers\Welcome@index');
//module routes
$hooks = Hooks::get();
$hooks->run('routes');
//if no route found
Router::error('Core\Error@index');
//turn on old style routing
Router::$fallback = false;
//execute matched routes
Router::dispatch();