In the coming sections, we will see how to build
applications over this framework.
Building Applications over our
Framework
Now is the colourful moment. So far, we have done so many things to ease
developing applications over our framework. So now in this section we will develop
a basic blog application and discuss how to take advantage of our framework.
For those unfamiliar with Blogs, they are simply web-based publishing systems,
where people are allowed to write anything and publish it. In this application we will
allow users to write articles, display them, and also allow users to publish comments.
Building Better with MVC
[ 242 ]
Let's create a MySQL database named packtblog with three tables; Users, Posts,
and Comments. Here is the database schema:
Table: Posts
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(250) | YES | | NULL | |
| content | text | YES | | NULL | |
| user_id | int(11) | YES | | NULL | |
| date | int(11) | YES | | NULL | |
+---------+--------------+------+-----+---------+----------------+
Table: Comments
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| post_id | int(11) | YES | | NULL | |
| content | text | YES | | NULL | |
| date | int(11) | YES | | NULL | |
| author | varchar(250) | YES | | NULL | |
+---------+--------------+------+-----+---------+----------------+
Table: Users
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
| fullname | varchar(250) | YES | | NULL | |
| email | varchar(250) | YES | | NULL | |
| password | varchar(32) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
Authentication Controller
Let's design our main controller with users who, will be able to register, or log into,
their system.
Pages:
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242