|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
|-------------------------------------------------------------------------- |
|
5
|
|
|
| Autoload |
|
6
|
|
|
|-------------------------------------------------------------------------- |
|
7
|
|
|
| |
|
8
|
|
|
| After running "composer install", we can use the autoloader file created. |
|
9
|
|
|
| |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
require '../vendor/autoload.php'; |
|
13
|
|
|
|
|
14
|
|
|
/* |
|
15
|
|
|
|-------------------------------------------------------------------------- |
|
16
|
|
|
| Define Application Configuration Constants |
|
17
|
|
|
|-------------------------------------------------------------------------- |
|
18
|
|
|
| |
|
19
|
|
|
| PUBLIC_ROOT: the root URL for the application (see below). |
|
20
|
|
|
| BASE_DIR: path to the directory that has all of your "app", "public", "vendor", ... directories. |
|
21
|
|
|
| IMAGES: path to upload images, don't use it for displaying images, use Config::get('root') . "/img/" instead. |
|
22
|
|
|
| APP: path to app directory. |
|
23
|
|
|
| |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
// Config::set('base', str_replace("\\", "/", dirname(__DIR__))); |
|
|
|
|
|
|
27
|
|
|
// Config::set('images', str_replace("\\", "/", __DIR__) . "/img/"); |
|
28
|
|
|
// Config::set('app', Config::get('base') . "/app/"); |
|
29
|
|
|
|
|
30
|
|
|
define('BASE_DIR', str_replace("\\", "/", dirname(__DIR__))); |
|
31
|
|
|
define('IMAGES', str_replace("\\", "/", __DIR__) . "/img/"); |
|
32
|
|
|
define('APP', BASE_DIR . "/app/"); |
|
33
|
|
|
|
|
34
|
|
|
/* |
|
35
|
|
|
|-------------------------------------------------------------------------- |
|
36
|
|
|
| Register Error & Exception handlers |
|
37
|
|
|
|-------------------------------------------------------------------------- |
|
38
|
|
|
| |
|
39
|
|
|
| Here we will register the methods that will fire whenever there is an error |
|
40
|
|
|
| or an exception has been thrown. |
|
41
|
|
|
| |
|
42
|
|
|
*/ |
|
43
|
|
|
|
|
44
|
|
|
Handler::register(); |
|
45
|
|
|
|
|
46
|
|
|
/* |
|
47
|
|
|
|-------------------------------------------------------------------------- |
|
48
|
|
|
| Start Session |
|
49
|
|
|
|-------------------------------------------------------------------------- |
|
50
|
|
|
| |
|
51
|
|
|
*/ |
|
52
|
|
|
|
|
53
|
|
|
Session::init(); |
|
54
|
|
|
|
|
55
|
|
|
/* |
|
56
|
|
|
|-------------------------------------------------------------------------- |
|
57
|
|
|
| Create The Application |
|
58
|
|
|
|-------------------------------------------------------------------------- |
|
59
|
|
|
| |
|
60
|
|
|
| Here we will create the application instance which will take care of routing |
|
61
|
|
|
| the incoming request to the corresponding controller and action method if valid |
|
62
|
|
|
| |
|
63
|
|
|
*/ |
|
64
|
|
|
|
|
65
|
|
|
$app = new App(); |
|
66
|
|
|
|
|
67
|
|
|
// Config::set('root', $app->request->root()); |
|
|
|
|
|
|
68
|
|
|
define('PUBLIC_ROOT', $app->request->root()); |
|
69
|
|
|
|
|
70
|
|
|
/* |
|
71
|
|
|
|-------------------------------------------------------------------------- |
|
72
|
|
|
| Run The Application |
|
73
|
|
|
|-------------------------------------------------------------------------- |
|
74
|
|
|
| |
|
75
|
|
|
| Once we have the application instance, we can handle the incoming request |
|
76
|
|
|
| and send a response back to the client's browser. |
|
77
|
|
|
| |
|
78
|
|
|
*/ |
|
79
|
|
|
|
|
80
|
|
|
$app->run(); |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.