From c2428b3a8f97ff3a5c125944ac2b6aee9b081734 Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Tue, 28 May 2024 12:00:57 +0200
Subject: [PATCH] aggiunta metodo set per la dipendeza Viewer (parte 150)

---
 public/index.php |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/public/index.php b/public/index.php
index e0b4641..78b39f2 100644
--- a/public/index.php
+++ b/public/index.php
@@ -2,30 +2,27 @@
 
 declare(strict_types= 1);
 
+define ("ROOT_PATH", dirname(__DIR__));
+
 spl_autoload_register(function ($class) {
-    require "src/". str_replace("\\", "/", $class). ".php";
+    require ROOT_PATH . "/src/". str_replace("\\", "/", $class). ".php";
  });
 
 $dotenv = new Framework\Dotenv;
-$dotenv->load(".env");
+$dotenv->load(ROOT_PATH . "/.env");
 
 set_error_handler("Framework\ErrorHandler::handleError");
 
 set_exception_handler("Framework\ErrorHandler::handleException");
 
 
-$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
-if ($path === false) {
-    throw new UnexpectedValueException("Malformed URL: {$_SERVER["REQUEST_URI"]}");
-}
+$router = require ROOT_PATH . "/config/routes.php";
 
-$segments = explode("/", $path);
-
-$router = require "config/routes.php";
-
-$container = require "config/services.php";
+$container = require ROOT_PATH . "/config/services.php";
 
 $dispatcher = new Framework\Dispatcher($router, $container);
 
-$dispatcher->handle($path);
+$request = Framework\Request::createFromGlobals();
+
+$dispatcher->handle($request);
     
\ No newline at end of file

--
Gitblit v1.8.0