Added: Signin Up, connection to the DB, validator, base controller, base view, environment file, User model

This commit is contained in:
2024-12-26 02:00:33 +01:00
parent d7b8aba072
commit 5bca9b12aa
9 changed files with 338 additions and 27 deletions

View File

@ -1,10 +1,11 @@
<?php
class View
{
public function render($view, $data = [], $layout = 'base')
{
// Extract variables to be accessible in the view
extract($data);
private $data = [];
public function render($view, $data = [], $layout = 'base') {
// Store the data
$this->data = $data;
// Capture the view content
ob_start();
@ -12,6 +13,13 @@ class View
$content = ob_get_clean();
// Include the base layout and inject the view content
require_once views . "layouts/$layout.php";
require_once views . "layouts/$layout.php";
}
/**
* Safely get a value from the data array
*/
public function get($key) {
return $this->data[$key] ?? null;
}
}