corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-17 2ab29e2c24787de9db710fb1271abfd9d07ac065
inizializzazione classe ErrorHandler (parte 105)
1 files added
1 files modified
36 ■■■■■ changed files
index.php 17 ●●●● patch | view | raw | blame | history
src/Framework/ErrorHandler.php 19 ●●●●● patch | view | raw | blame | history
index.php
@@ -2,19 +2,15 @@
declare(strict_types= 1);
set_error_handler(function(
    int $errno,
    string $errstr,
    string $errfile,
    int $errline
    ): bool
    {
        throw new ErrorException($errstr,0, $errno, $errfile, $errline);
spl_autoload_register(function ($class) {
    require "src/". str_replace("\\", "/", $class). ".php";
});
set_error_handler("Framework\ErrorHandler::handleError");
set_exception_handler(function (Throwable $exception) {
    static $show_errors = false;
    static $show_errors = true;
    if($exception instanceof Framework\Exceptions\PageNotFoundException) {
        http_response_code(404);
@@ -35,9 +31,6 @@
    throw $exception;
});
spl_autoload_register(function ($class) {
    require "src/". str_replace("\\", "/", $class). ".php";
 });
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
if ($path === false) {
src/Framework/ErrorHandler.php
New file
@@ -0,0 +1,19 @@
<?php
declare(strict_types= 1);
namespace Framework;
use ErrorException;
class ErrorHandler {
    public static function handleError(
        int $errno,
        string $errstr,
        string $errfile,
        int $errline
        ): bool
        {
            throw new ErrorException($errstr,0, $errno, $errfile, $errline);
    }
}