‫Okay.
‫So now we're going to start our folder refactor.
‫And like I said in the last video we're going to have two kind of main folders.
‫One will be framework and one will be app.
‫So let's create a folder called framework.
‫And we're going to give it an uppercase F.
‫And we'll create app which will also have an uppercase A.
‫So what I want to move into framework is going to be right now just the database class and the router
‫okay.
‫So we're going to move those into framework.
‫Technically we could put helpers in there.
‫But I want to keep it I want to keep it all the classes the main classes.
‫So helpers I'm just going to keep that in the root.
‫And I should mention that there's no right or wrong way to to do this to structure an application,
‫especially, you know, a vanilla PHP application.
‫There's millions of ways you could do this.
‫So this is just kind of my preference and what I think makes sense for something like this.
‫You might want to change things around and that's absolutely fine.
‫So right now if I reload it's going to break because I moved those two files.
‫So I'm going to go into my public index.php where I'm loading these two files and I'm just going to
‫add framework to the front of them.
‫So we'll say framework slash router and framework slash database.
‫Reload that.
‫And now that works.
‫Okay, now for the app folder.
‫Let's move our controllers and our views into that.
‫Because remember the app folder represents the actual job listing website with the resources for that.
‫Which are the controllers views.
‫We're not really going to have models, but if you did you would put those in here.
‫And then the framework is more for stuff that doesn't.
‫You could reuse it very easily right in another application.
‫So again we're going to move controllers.
‫So let's move that into app and let's move views.
‫Into app.
‫And this also just cleans up the root folder really well.
‫Okay so we have app controllers views now where we have our router.
‫So if I reload the page again it's going to break.
‫So let's go to let's see.
‫We're going to go into our framework and then router and down where we're requiring the controller which
‫is in the root method.
‫So right here base path root controller.
‫We're just going to add on to this.
‫Let's say app slash.
‫And then we're going to concatenate that route controller.
‫Okay.
‫So we want to do that now we're seeing this view.
‫View home not found.
‫That's because in our helpers file where we have our load view.
‫Let's see.
‫So right here load view our view path.
‫We're just going to want to add app slash to that same thing with the partials the partial path.
‫So app slash.
‫And now that's working again.
‫Okay, so that's pretty much the first step of doing this.
‫What I would like to do next is get into auto loaders, because a lot of times you're going to have
‫tons and tons of classes.
‫You know, we only have two main classes in our framework here.
‫But you could have, you know, ten, 15, 20 classes and you're not going to want to require them all,
‫you know, everywhere where they need to be.
‫So we can have an auto loader that basically says any class that's in here, if it's called like database,
‫for instance, then automatically require a file called database.
‫Okay.
‫So we're going to start off with just creating a very simple custom auto loader.
‫Just so you know how to do that.
‫And then we're going to move on to use something called a PSR for auto loader, which we can use by
‫installing setting up setting that up with composer, which is the PHP package manager.
‫So we'll get into all that next.