From 4d29a48f79e02bf28ce8b9af539e0be4e62bbac1 Mon Sep 17 00:00:00 2001 From: Damillora Date: Mon, 18 Nov 2019 02:22:25 +0700 Subject: [PATCH] Minggu 17 November 2019 --- README.md | 59 +++++++++++++++++++ .../Controllers/IndexController.php | 12 ++++ backend/Mitsumine/HTTP/Request.php | 6 ++ backend/Mitsumine/Services/Config.php | 12 ++++ backend/Mitsumine/Services/Database.php | 12 ++++ .../Mitsumine/Services/ServiceContainer.php | 21 +++++++ backend/autoload.php | 14 +++++ backend/config.php | 7 +++ backend/index.php | 48 +++++++++++++++ backend/routes.php | 6 ++ frontend/index.html | 18 ++++++ index.php | 18 ++++++ 12 files changed, 233 insertions(+) create mode 100644 README.md create mode 100644 backend/Application/Controllers/IndexController.php create mode 100644 backend/Mitsumine/HTTP/Request.php create mode 100644 backend/Mitsumine/Services/Config.php create mode 100644 backend/Mitsumine/Services/Database.php create mode 100644 backend/Mitsumine/Services/ServiceContainer.php create mode 100644 backend/autoload.php create mode 100644 backend/config.php create mode 100644 backend/index.php create mode 100644 backend/routes.php create mode 100644 frontend/index.html create mode 100644 index.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..77d3add --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# Metaforums +An online web-based discussion forum application + +## Project Structure +This project is separated between the frontend and the backend application. +- backend/ + The backend of this application is written in PHP, and is API focused. + - index.php + The main handler of backend functions. Handles routing, loading of Mitsumine services, and conversion of array responses to JSON. + - Mitsumine/ + Mitsumine is a set of custom-written helper classes to consolidate frequently used code. + - Mitsumine/HTTP + Mitsumine HTTP contains a number of abstractions for HTTP, such as Request class + - Mitsumine/Services + Mitsumine Services contains a number of service classes for common functionality such as Database and Session. + - Application/ + Application contains classes that are the core of the application itself + - Controllers/ + Controllers contain controllers that return HTTP responses +- frontend/ + The frontend of this application, written in HTML and utilizes T +- index.php + This index file allows serving both frontend and backend from one endpoint. + +## Software Stack + +The software is tested on the Apache server and PHP 7.3 on Arch Linux. + +## Backend + +The database used is MariaDB 10.4.8 + +## External frontend libraries used + +### Vue.js + +Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web + +Vue.js allows for interactivity while being less cumbersome than manipulating the DOM manually e.g. with jQuery. + +[Project Website](https://vuejs.org) + +### jQuery + +jQuery is a feature-rich JavaScript library. + +Here, jQuery is mainly used for its AJAX functionality. + +[Project Website](https://jquery.com) + +## CSS Frameworks and Styles used + +### Tailwind + +Tailwind is a utility-first CSS framework for rapidly building custom designs + +[Project Website](https://tailwindcss.com) + +## Additional Development diff --git a/backend/Application/Controllers/IndexController.php b/backend/Application/Controllers/IndexController.php new file mode 100644 index 0000000..9c1e072 --- /dev/null +++ b/backend/Application/Controllers/IndexController.php @@ -0,0 +1,12 @@ + 'yuika' + ]; + } +} diff --git a/backend/Mitsumine/HTTP/Request.php b/backend/Mitsumine/HTTP/Request.php new file mode 100644 index 0000000..1f59ff3 --- /dev/null +++ b/backend/Mitsumine/HTTP/Request.php @@ -0,0 +1,6 @@ +configs = require 'backend/config.php'; + } + public function __call($name, $args) { + return $this->configs[$name]; + } +} diff --git a/backend/Mitsumine/Services/Database.php b/backend/Mitsumine/Services/Database.php new file mode 100644 index 0000000..d97d696 --- /dev/null +++ b/backend/Mitsumine/Services/Database.php @@ -0,0 +1,12 @@ +conn = mysqli_connect($config->db_host(),$config->db_user(),$config->db_pass(),$config->db_name()); + } +} diff --git a/backend/Mitsumine/Services/ServiceContainer.php b/backend/Mitsumine/Services/ServiceContainer.php new file mode 100644 index 0000000..f43e917 --- /dev/null +++ b/backend/Mitsumine/Services/ServiceContainer.php @@ -0,0 +1,21 @@ + 'metaforums', + 'db_host' => '127.0.0.1', + 'db_user' => 'root', + 'db_pass' => '', +]; diff --git a/backend/index.php b/backend/index.php new file mode 100644 index 0000000..98f67df --- /dev/null +++ b/backend/index.php @@ -0,0 +1,48 @@ +$method($request); + +// Convert array to JSON +if(is_array($result)) { + header('Content-Type: application/json'); + $result = json_encode($result); +} +echo $result; + diff --git a/backend/routes.php b/backend/routes.php new file mode 100644 index 0000000..c3ae232 --- /dev/null +++ b/backend/routes.php @@ -0,0 +1,6 @@ + [ + 'controller' => 'IndexController@index', + ], +]; diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..6c39777 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,18 @@ + + + + + +
+{{ message }} +
+ + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..559d73e --- /dev/null +++ b/index.php @@ -0,0 +1,18 @@ +