diff --git a/app/controllers/AuthController.php b/app/controllers/AuthController.php new file mode 100644 index 0000000..f188111 --- /dev/null +++ b/app/controllers/AuthController.php @@ -0,0 +1,19 @@ + 'Log In' + ]; + $view->render('auth/signin', $data); + } + + public function signup() { + $view = new View(); + $data = [ + 'title' => 'Register' + ]; + $view->render('auth/signup', $data); + } +} diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php new file mode 100644 index 0000000..33bdcc7 --- /dev/null +++ b/app/controllers/HomeController.php @@ -0,0 +1,22 @@ + 'Home' + ]; + $view->render('home/index', $data); + //require_once views . 'home/index.php'; + } + + public function home() { + $this->index(); + } +} diff --git a/app/views/auth/signin.php b/app/views/auth/signin.php new file mode 100644 index 0000000..c1ea56a --- /dev/null +++ b/app/views/auth/signin.php @@ -0,0 +1,9 @@ +
+
+ + + + + +
+
diff --git a/app/views/auth/signup.php b/app/views/auth/signup.php new file mode 100644 index 0000000..d55a20f --- /dev/null +++ b/app/views/auth/signup.php @@ -0,0 +1,11 @@ +
+
+ + + + + + + +
+
diff --git a/app/views/dashboard/index.php b/app/views/dashboard/index.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/errors/404.php b/app/views/errors/404.php new file mode 100644 index 0000000..6131d3a --- /dev/null +++ b/app/views/errors/404.php @@ -0,0 +1,13 @@ + + + + + + + Habit Tracker | Error 494 + + +

Error 404 - Page not found

+ Go back home + + diff --git a/app/views/habits/create.php b/app/views/habits/create.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/habits/edit.php b/app/views/habits/edit.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/home/index.php b/app/views/home/index.php new file mode 100644 index 0000000..98ee066 --- /dev/null +++ b/app/views/home/index.php @@ -0,0 +1,4 @@ +
+

Welcome to Habit Tracker!

+

Track your habits and achieve your goals.

+
diff --git a/app/views/layouts/base.php b/app/views/layouts/base.php new file mode 100644 index 0000000..8b59e50 --- /dev/null +++ b/app/views/layouts/base.php @@ -0,0 +1,16 @@ + + + + + Habit Tracker | <?= $data['title'] ?> + + +
+ Log In + Sign Up +
+
+ +
+ + diff --git a/app/views/shared/footer.php b/app/views/shared/footer.php new file mode 100644 index 0000000..e69de29 diff --git a/app/views/shared/header.php b/app/views/shared/header.php new file mode 100644 index 0000000..1a9c6c2 --- /dev/null +++ b/app/views/shared/header.php @@ -0,0 +1,4 @@ +
+ Log In + Sign Up +
diff --git a/core/Controller.php b/core/Controller.php new file mode 100644 index 0000000..e69de29 diff --git a/core/Router.php b/core/Router.php new file mode 100644 index 0000000..d373bb8 --- /dev/null +++ b/core/Router.php @@ -0,0 +1,28 @@ +routes[$route] = $action; + } + + public function dispatch() { + $uri = $_SERVER['REQUEST_URI']; + $uri = parse_url($uri, PHP_URL_PATH); + + if (array_key_exists($uri, $this->routes)) { + $action = $this->routes[$uri]; + list($controllerName, $methodName) = explode('@', $action); + + require_once controllers . "{$controllerName}.php"; + + $controller = new $controllerName(); + $controller->$methodName(); + } else { + http_response_code(404); + $view = new View(); + $view->render('errors/404'); + } + } +} diff --git a/core/View.php b/core/View.php new file mode 100644 index 0000000..4cc6fb9 --- /dev/null +++ b/core/View.php @@ -0,0 +1,17 @@ +add('/', 'HomeController@index'); +$router->add('/home', 'HomeController@home'); + +// auth routes +$router->add('/auth/signin', 'AuthController@signin'); +$router->add('/auth/signup', 'AuthController@signup'); +$router->dispatch(); diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore new file mode 100644 index 0000000..397b4a7 --- /dev/null +++ b/storage/logs/.gitignore @@ -0,0 +1 @@ +*.log