You're using a closure which means the $db
variable is no longer in scope. You need to use the use
keyword to tell PHP to allow the use of the variable from the parent scope.
$f3->route('GET /', function($f3) use ($db) {
$f3->set('result', $db->exec('SELECT achternaam FROM test1'));
$template = new Template;
echo $template->render('views/homepage.html');
});
$f3->run();