<?php    
    public function run() {
    try {
        $db = $this->openDatabaseConnection();
        $this->dispatchToController($db);
    }
    catch(AccessDeniedException $e) {
        require_once 'app/controller/error.php';
        $controller = new ErrorController($db);
        $controller->accessDenied();
    }
    catch(NotFoundException $e) {
        require_once 'app/controller/error.php';
        $controller = new ErrorController($db);
        $controller->notFound();
    }
    catch(\Exception $e) {
        if(PRODUCTION) {
        require_once 'app/controller/error.php';
        $controller = new ErrorController($db);
        $controller->unknown();
        }
        
    }
}
the $db is defined on top, the snippet was run on ngnix web server with PHP 7.4.33 and gave the following error [500]: GET / - Uncaught ErrorException: Undefined variable: db
 
     
    