added session, moved twig, updated base

This commit is contained in:
2024-09-12 16:28:33 -07:00
parent f19f59d53a
commit 937e4581ba
3 changed files with 77 additions and 15 deletions

View File

@@ -2,21 +2,12 @@
require_once(BASEPATH . '/vendor/autoload.php');
require_once(BASEPATH . '/App/config.php');
//Twig
function view($name = '', $data = [] ) {
$loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
$loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
$loader->addPath(BASEPATH . '/App/templates', 'override');
$twig = new Twig\Environment($loader);
//check if file exists
if (file_exists(BASEPATH . '/App/views/' . $name . '.html.twig')) {
echo $twig->render("$name" . '.html.twig', $data);
return true;
} else {
echo "Error: Twig Template ($name) Not Found.";
return false;
}
}
// Creates twig and the view() function
require_once(BASEPATH . '/vendor/4lt/novaconium/src/twig.php');
// Start a Session
require_once(BASEPATH . '/vendor/4lt/novaconium/src/Session.php');
$session = new Session();
// Load Database Class
require_once(BASEPATH . '/vendor/4lt/novaconium/src/Database.php');
@@ -27,3 +18,6 @@ require_once(BASEPATH . '/vendor/4lt/novaconium/src/Router.php');
$router = new Router();
//$router->debug();
require_once($router->controllerPath);
//write the session
$session->write();