From addab242fe3986ab8e76aaa4448609ffbf9616ab Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Thu, 16 May 2024 10:30:04 +0200
Subject: [PATCH] aggiunta possibilità di vedere gli errori o no (parte 98)

---
 index.php |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/index.php b/index.php
index b6fbdfa..2227691 100644
--- a/index.php
+++ b/index.php
@@ -1,10 +1,24 @@
 <?php
 
+declare(strict_types= 1);
+$show_errors = true;
+
+if($show_errors) {
+    ini_set("display_errors", "1");
+}else{
+    ini_set("display_errors","0");
+}
+
+
 spl_autoload_register(function ($class) {
     require "src/". str_replace("\\", "/", $class). ".php";
  });
 
 $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+if ($path === false) {
+    throw new UnexpectedValueException("Malformed URL: {$_SERVER["REQUEST_URI"]}");
+}
+
 $segments = explode("/", $path);
 
 $router = new Framework\Router;
@@ -20,6 +34,11 @@
 
 $container = new Framework\Container;
 
+
+$container->set(App\Database::class, function() {
+    return new App\Database("localhost", "product_db", "product_db_user", "secret");
+});
+
 $dispatcher = new Framework\Dispatcher($router, $container);
 
 $dispatcher->handle($path);

--
Gitblit v1.8.0