corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-27 21de70eae059061dec2df437b5435a586bcf0341
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
<?php
 
declare(strict_types= 1);
 
define ("ROOT_PATH", dirname(__DIR__));
 
spl_autoload_register(function ($class) {
    require ROOT_PATH . "/src/". str_replace("\\", "/", $class). ".php";
 });
 
$dotenv = new Framework\Dotenv;
$dotenv->load(ROOT_PATH . "/.env");
 
set_error_handler("Framework\ErrorHandler::handleError");
 
set_exception_handler("Framework\ErrorHandler::handleException");
 
 
$router = require ROOT_PATH . "/config/routes.php";
 
$container = require ROOT_PATH . "/config/services.php";
 
$dispatcher = new Framework\Dispatcher($router, $container);
 
$request = new Framework\Request($_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"]);
 
$dispatcher->handle($request);