Okay, guys, let's take a look at the first project that we are going to build.
It is a personal portfolio.
But the interesting part here is the dynamic part.
So people can leave public notes that we're gonna store in the database.
And then they all will be displayed on this guestbook page, sorted from the most recent one to the
oldest ones.
Additionally, the username and email here would be obfuscated, so it is not really publicly visible.
Now, while this might not really look like it, you're gonna learn quite a lot of concepts in this
simple projects.
Let me at least mention some of them, or the most important concepts that we're gonna learn throughout
this project.
Keep in mind, we're not gonna learn all the concepts that I have planned for this course.
So starting with PDO, this is a database abstraction that lets you use one single interface to connect
to different databases.
We're going to start with an SQLite database that doesn't really require you to install any database
server.
Next up, we're gonna learn some security principles like the cross-site request forgery protection.
This is used with forms.
I'm gonna be going into details about that.
Prepared statements to not let anyone inject any additional SQL when sending data through the forms.
This is an essential protection that you should always use.
Then we're going to be creating forms and validating the data that is sent through those forms.
Obviously working with databases, storing data, reading data, you're gonna see how can you sort the
data that you read.
Next up I'm going to cover the concept of routing.
This is having just one entry file index.php inside your application, which then decides what code
should be loaded and run for a specific path.
Then the design pattern called model view controller.
This is a design pattern for your whole application.
It's pretty simple, but it is something that is most popular in PHP world.
So the simple concept is to divide the data handling into model.
The generating of HTML into view and controller is the part that controls everything.
And finally I'm going to introduce the concept of templating.
So creating special files which only job is to be a template from which you're going to be generating
the final HTML.
Now finally let's review the structure of the app.
So as I said we're going to be using the model view controller.
And let's talk about every single part of this MVC division.
So in purple we've got folders there that our app would have.
Let me start with the controller part.
So I'm going to zoom in now.
As I've said previously, the entry point to our app is always this file public index.php.
It's also called a front controller.
And then we got this routes folder.
So the URI must match the file name plus the method.
This is our simplified routing mechanism, which means that if there is a Get request for slash contact,
this file would be loaded if there is a Post request for slash contact.
So this is for example a form that is being sent.
We're going to be looking for that file.
So you just need to create those files that match the path plus the method.
Super simple, but I think it is a good starting idea.
And another example, the guest book obviously loads this file.
So then we are moving into the model.
So the model is where we store the data and the functions that we provide to interact with the data.
So we're going to have a schema file to define all the tables and the structure.
We are using the SQLite.
So we're going to be storing that in a one single file.
And then the db php file will have all the code that is responsible for connecting to the database,
getting the data, inserting the data, etc. thus the model interacting with the data.
Now this name controller probably tells you something.
It's controller because controllers control the whole process of getting some data or inserting data.
Then passing this data to templates, which would be simple HTML files, which only job is to output
HTML optionally with some data.
That's why controllers will pass the data that it is fetching using models to our templates, producing
the so-called views.
That's why this is our view department.
And finally the view will return back the HTML.
Which controller can return back as a response for a request.
So as you see, while this might have looked like initially like a tiny funny website, it's actually
not.
We're gonna be introducing a lot of concepts, and there is a lot on the plate.
So let's prepare ourselves and let's get started.