CVWO Assignmment 1: A simple blog app
This repository contains a very basic blogging app, which allows multiple writers to login, thereby to create and manage content. The app also allows for public comments on each blog post.
Shen Yichen (A0091173J)
- PHP 5.6
mod_rewrite
needs to be activated- MySQL 5.6
This app is based on the MINI PHP framework, and adopts MVC principles approximately.
Install the schema by running db/schema_install.sql
.
# From system terminal
mysql -u root -p < db/schema_install.sql
# OR
# From MySQL terminal
source db/schema_install.sql
This scripts creates the blog schema in MySQL and sets up the tables accordingly. No data will be loaded.
MySQL user configs are located in src/application/config/config.php
. Edit them accordingly to connect to your MySQL database.
Alternatively, for a local MySQL server, create a user with the following credentials, which will allow connection with default settings.
user: blog
password: cvwoblog
Test data can be found in db/test_data.sql
. Run this script after the schema script, in the same fashion, if you wish to initialize the database with initial data.
The test data comes with 2 writer accounts:
user: admin
password: admin
user: editor
password: writer
Copy the contents of src/
to your server root and start the server. Make sure the requirements are statisfied.
In an UNIX environment, you can also use mount --bind
to quickly and temporarily set-up the server. For example:
#For an apache server
mount --bind src/ /var/www/html/
The app is based on the MINI PHP framework, and follows a MVC structure roughly. You may want to check out MINI's documentation.
The src/public/
folder contains the index page which is the entry point for the app. It also contains the neccessary resourses such as Javascript and CSS files that the app depends on.
The Bootstrap CSS framework is included.
The src/application/model
folder contains the models. Each model corresponds to a resource in the database, and provides methods to create, edit, delete and query them.
SQL code is directly coded into the models, and are used together with PDO to access the database.
The 'src/application/controller' folder contains the controllers, obtaining data from the models and setting them up for the views.
Each method in a controller corresponds to an URL, as explained in the MINI documentation. Just allowing for a quick API to be set-up.
The 'src/application/view' folder contains the views for the app. _templates
contains reusable HTML which can be set-up either in the controllers or within the view itself. The rest of the views corresponds to features of the app.
This app is released under the MIT license, refer to the LICENSE file for details.