Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
98.00% |
49 / 50 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /* |
3 | * This file is part of One Project. |
4 | * |
5 | * For the full copyright and license information, please view the LICENSE |
6 | * file that was distributed with this source code. |
7 | */ |
8 | if (class_exists(Composer\Autoload\ClassLoader::class, false) === false |
9 | && is_file(__DIR__ . '/../vendor/autoload.php') |
10 | ) { |
11 | require __DIR__ . '/../vendor/autoload.php'; |
12 | } |
13 | |
14 | use Framework\Log\LogLevel; |
15 | use Framework\MVC\App; |
16 | use Framework\Routing\RouteCollection; |
17 | use Framework\Routing\Router; |
18 | |
19 | define('ENVIRONMENT', $_SERVER['ENVIRONMENT'] ?? 'production'); |
20 | |
21 | (new App([ |
22 | 'exceptionHandler' => [ |
23 | 'default' => [ |
24 | 'environment' => ENVIRONMENT, |
25 | 'initialize' => true, |
26 | 'logger_instance' => 'default', |
27 | ], |
28 | ], |
29 | 'logger' => [ |
30 | 'default' => [ |
31 | 'destination' => __DIR__ . '/../storage/logs', |
32 | 'level' => LogLevel::ERROR, |
33 | ], |
34 | ], |
35 | 'request' => [ |
36 | 'default' => [ |
37 | 'allowed_hosts' => [ |
38 | 'localhost:8080', |
39 | ], |
40 | 'force_https' => ENVIRONMENT !== 'development', |
41 | ], |
42 | ], |
43 | 'response' => [ |
44 | 'default' => [ |
45 | 'auto_etag' => true, |
46 | ], |
47 | ], |
48 | 'router' => [ |
49 | 'default' => [ |
50 | 'auto_methods' => true, |
51 | 'auto_options' => true, |
52 | 'callback' => static function (Router $router) : void { |
53 | $router->serve(null, static function (RouteCollection $routes) : void { |
54 | $routes->get('/', static function () : array { |
55 | return [ |
56 | 'message' => 'I am the One! You found me.', |
57 | ]; |
58 | }); |
59 | $routes->notFound(static fn () : array => [ |
60 | 'message' => 'Route not found.', |
61 | ]); |
62 | }); |
63 | }, |
64 | ], |
65 | ], |
66 | ], ENVIRONMENT === 'development'))->runHttp(); |