WEBVTT

00:01.670 --> 00:07.010
Okay, guys, let's take a look at the first project that we are going to build.

00:07.010 --> 00:09.500
It is a personal portfolio.

00:09.500 --> 00:13.790
But the interesting part here is the dynamic part.

00:13.790 --> 00:19.640
So people can leave public notes that we're gonna store in the database.

00:19.640 --> 00:27.440
And then they all will be displayed on this guestbook page, sorted from the most recent one to the

00:27.440 --> 00:28.610
oldest ones.

00:28.640 --> 00:36.890
Additionally, the username and email here would be obfuscated, so it is not really publicly visible.

00:37.850 --> 00:44.360
Now, while this might not really look like it, you're gonna learn quite a lot of concepts in this

00:44.360 --> 00:45.590
simple projects.

00:45.620 --> 00:52.670
Let me at least mention some of them, or the most important concepts that we're gonna learn throughout

00:52.670 --> 00:53.330
this project.

00:53.330 --> 00:59.660
Keep in mind, we're not gonna learn all the concepts that I have planned for this course.

00:59.660 --> 01:07.630
So starting with PDO, this is a database abstraction that lets you use one single interface to connect

01:07.630 --> 01:09.400
to different databases.

01:09.400 --> 01:16.360
We're going to start with an SQLite database that doesn't really require you to install any database

01:16.360 --> 01:17.200
server.

01:17.230 --> 01:25.600
Next up, we're gonna learn some security principles like the cross-site request forgery protection.

01:25.630 --> 01:27.310
This is used with forms.

01:27.310 --> 01:30.310
I'm gonna be going into details about that.

01:30.370 --> 01:40.150
Prepared statements to not let anyone inject any additional SQL when sending data through the forms.

01:40.150 --> 01:45.010
This is an essential protection that you should always use.

01:45.160 --> 01:51.340
Then we're going to be creating forms and validating the data that is sent through those forms.

01:51.430 --> 01:58.360
Obviously working with databases, storing data, reading data, you're gonna see how can you sort the

01:58.360 --> 02:00.190
data that you read.

02:00.220 --> 02:04.420
Next up I'm going to cover the concept of routing.

02:04.420 --> 02:13.560
This is having just one entry file index.php inside your application, which then decides what code

02:13.560 --> 02:17.580
should be loaded and run for a specific path.

02:17.820 --> 02:22.980
Then the design pattern called model view controller.

02:22.980 --> 02:27.000
This is a design pattern for your whole application.

02:27.000 --> 02:33.570
It's pretty simple, but it is something that is most popular in PHP world.

02:33.570 --> 02:39.540
So the simple concept is to divide the data handling into model.

02:39.900 --> 02:47.220
The generating of HTML into view and controller is the part that controls everything.

02:47.520 --> 02:51.330
And finally I'm going to introduce the concept of templating.

02:51.330 --> 03:00.120
So creating special files which only job is to be a template from which you're going to be generating

03:00.120 --> 03:02.400
the final HTML.

03:04.110 --> 03:07.680
Now finally let's review the structure of the app.

03:07.680 --> 03:12.410
So as I said we're going to be using the model view controller.

03:12.410 --> 03:18.830
And let's talk about every single part of this MVC division.

03:18.830 --> 03:24.080
So in purple we've got folders there that our app would have.

03:24.110 --> 03:26.870
Let me start with the controller part.

03:26.870 --> 03:28.880
So I'm going to zoom in now.

03:29.990 --> 03:37.040
As I've said previously, the entry point to our app is always this file public index.php.

03:37.100 --> 03:40.340
It's also called a front controller.

03:40.490 --> 03:44.420
And then we got this routes folder.

03:44.420 --> 03:49.760
So the URI must match the file name plus the method.

03:49.760 --> 03:57.470
This is our simplified routing mechanism, which means that if there is a Get request for slash contact,

03:57.500 --> 04:02.930
this file would be loaded if there is a Post request for slash contact.

04:02.930 --> 04:06.830
So this is for example a form that is being sent.

04:06.830 --> 04:09.020
We're going to be looking for that file.

04:09.020 --> 04:15.380
So you just need to create those files that match the path plus the method.

04:15.380 --> 04:20.120
Super simple, but I think it is a good starting idea.

04:20.120 --> 04:24.080
And another example, the guest book obviously loads this file.

04:24.170 --> 04:29.360
So then we are moving into the model.

04:29.360 --> 04:36.980
So the model is where we store the data and the functions that we provide to interact with the data.

04:36.980 --> 04:41.990
So we're going to have a schema file to define all the tables and the structure.

04:41.990 --> 04:44.030
We are using the SQLite.

04:44.030 --> 04:47.750
So we're going to be storing that in a one single file.

04:47.750 --> 04:56.480
And then the db php file will have all the code that is responsible for connecting to the database,

04:56.480 --> 05:03.950
getting the data, inserting the data, etc. thus the model interacting with the data.

05:04.850 --> 05:08.810
Now this name controller probably tells you something.

05:08.840 --> 05:17.770
It's controller because controllers control the whole process of getting some data or inserting data.

05:17.800 --> 05:27.070
Then passing this data to templates, which would be simple HTML files, which only job is to output

05:27.370 --> 05:31.210
HTML optionally with some data.

05:31.240 --> 05:39.610
That's why controllers will pass the data that it is fetching using models to our templates, producing

05:39.610 --> 05:41.350
the so-called views.

05:41.380 --> 05:45.700
That's why this is our view department.

05:45.940 --> 05:50.680
And finally the view will return back the HTML.

05:50.680 --> 05:56.230
Which controller can return back as a response for a request.

06:00.520 --> 06:07.870
So as you see, while this might have looked like initially like a tiny funny website, it's actually

06:07.870 --> 06:08.710
not.

06:08.740 --> 06:15.100
We're gonna be introducing a lot of concepts, and there is a lot on the plate.

06:15.100 --> 06:19.630
So let's prepare ourselves and let's get started.
