corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-27 27699b4cdf7b150acaf8b3d36bee7b3d844682a3
inizializzazione classe Request per gestire le richieste (parte 145)
1 files added
2 files modified
18 ■■■■ changed files
public/index.php 4 ●●● patch | view | raw | blame | history
src/Framework/Dispatcher.php 2 ●●● patch | view | raw | blame | history
src/Framework/Request.php 12 ●●●●● patch | view | raw | blame | history
public/index.php
@@ -28,5 +28,7 @@
$dispatcher = new Framework\Dispatcher($router, $container);
$dispatcher->handle($path, $_SERVER["REQUEST_METHOD"]);
$request = new Framework\Request($_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"]);
$dispatcher->handle($request);
    
src/Framework/Dispatcher.php
@@ -9,7 +9,7 @@
    public function __construct(private Router $router,
                                private Container $container) { }
    public function handle(string $path, $method) {
    public function handle(Request $request) {
        $params = $this->router->match($path, $method);
        if($params === false) {
src/Framework/Request.php
New file
@@ -0,0 +1,12 @@
<?php
declare(strict_types= 1);
namespace Framework;
class Request {
    public function __construct(public string $uri, public string $method) {
    }
}