 Hey everybody, it's Brian and welcome to the 13th year to tutorial We are going to be switching things up a little bit. We've been working with what was it pet store and Admittedly I hated the design. So I'm also a big fan of learning by doing and I've had a lot of good feedback on my Facebook channel So what we're gonna do is we're gonna actually build a website from start to finish and here's kind of our curriculum if you will Haven't actually counted these up. This probably isn't even the end But we're gonna start tonight with the database design Actually building the web app and if we have time going into ghee, although I got a feeling that may actually be the second tutorial We'll find out All the way up to like actually sending emails and registration and you know, etc. Etc. So what is the purpose of this site? What's it gonna do? Let's pull up our database here. We're going to make yet another blog site It's a really good example because it allows you to do data entry, you know Because you need more data entry in your life. Anyways, no really what we've got is we're gonna have accounts and let me actually pull that up here So people can join your site and When they join it will create an account We've got our off key and access token, which is going to be needed by the security model And they'll join with an email and password and then we have a little bit flag in here called registered meaning they're gonna have to actually Register they can't just join so when they join an email is going to get kicked out They're gonna have to click a link it'll go back into your e-site and it'll register them in the database Very simple database design. It just has accounts blogs and categories So the premise of this is that they can go in and create their own categories. Let me Look at this categories dead simple. I mean just you've got a foreign key To the accounts which is set to cascade. So if they delete their account all the categories the creator deleted with it same thing with blogs Alter table here Got a foreign key to accounts Set to cascade. So when they delete their account all their blogs are also deleted I've got a bit field called publish. So until they actually publish it. It won't be you know Publicly searchable and just a date publish the title and then the body. So it's very very simple database design I wanted it simple because well Simple's good and we're focused on ye not database design so If you need to view that again, just rewind the video But that's our database setup and I'll try to put the actual sequel dump out on my website as well So we're going to just dump or dump cheese jump right in here This is my var dub dub dub HTML directory as you can see I've got a couple other websites out there We are going to actually go in and create using composer. Oh My god, my cat hears me talking Now if you remember from previous tutorials here That command out on their website actually does not work for me If I do PHP composer PHP HR doesn't work because I've done the global installation So I'm going to say composer and you'll see how it works for me See to the composer so Let me bring this up. I'm going to actually Grab this copy that I'm gonna go CD because I'm gonna change directory here And we're gonna go in there and then I'm just gonna go composer Poser God, I cannot spell composer I've been in I make C++ tutorials with cute some of you may have watched them and I've been thinking in purely C++ for like weeks now. So my brain's a little stuck So what this does if you're just now tuning in we've covered this before is Composer will go out and it will create a project using the EE soft e2 app basic And we're going to name this blogger and we're going to use the 2.07 build And we're going to get some warnings here and this is going to take a little bit of time So just fast forward through this because I really am horrible about video editing So I'm not going to like stop time and re-edit the video and all that We're just going to wait for this to go and if you don't like it fast forward all right, so Let's I had to keep you entertained while this is downloading. So some of the things that I really want to cover with this is The user form how to join somebody to your website and then we have to test that right because There's a whole process the user is going to come they're going to click join they're going to enter there your email and password and Then you're going to create a record. We're going to kick out an email So we have to you know learn how to set up email Email has its own special views and way of doing things and then we have to actually send the email We have to do error handling. That's important email and yee is pretty straightforward, but there's some caveats We really got to understand Then we got to do things like account activation we got to have a model for that obviously We need to have like, you know changing their information their username their email their password And I'm going to break those up into separate pages just so it's nice and pretty for the end user Then categories and this is mostly key stuff right we're going to say categories They're going to be able to manage it, which is you know the crud they're going to go in they're going to add Edit delete etc. etc same thing with blogs Categories have to come before blogs because well you had to build the categories The search method is going to be kind of towards the end. That's where we have publicly available searches All right, so we are done there. Let me Now that i'm sitting here talking, let's actually make sure our database is what we wanted it to be Yeah, see I don't have a category in here gr You're gonna have to do a little bit of database maintenance here All right, so we're gonna put that here Notice how it has to be a big end if we're going to relate to the other keys It doesn't have to be a big end. It just has to match the keys Yeah, as I was talking I was like man, I think I screwed that up. So Category categories And we're going to cascade because if would they delete a category we want to delete all the blogs that are in that category Because why not? Close all right good. So now we've got our foreign key relationships here And my sequel's been a bit glitchy So I always like to just go back in there and just view everything and make sure it actually stayed I had a separate project I was working on where I was working away and everything was fine and then all of a sudden None of the changes that I made saved. I was so mad I was so mad that you know, I went had a rum and coke and played video games for five hours because why not? all right, so What we want to do now Is verify that blogger actually did get created which it did we can If you're not liking the command line, you can go out and see it now From previous tutorials, you know that if we go in and directly start using g we're going to get read write errors So what I like to do and this is not best practice. I'm going to stress that I do this strictly in development Okay, I changed the owner What I'm doing now is I'm just simply giving it a group, right? There dub dub dub HTML blogger And then I'm going to do it recursively. So we're going to just Whoopsie. Yeah, not permitted. We should probably do a sudo. I forgot about that. All right, good. So Clear all that nonsense out of there Then we're going to change the mode or change mod as you call it I'm going to do user group other. This is a huge security violation Do never never ever do this in production repeat after me never ever ever do this in production Um, so what do you do in production if this is not the correct thing? Well, that's good to quick question to ask I would rely on your internet provider or your isp or your web provider. Whoever is your host They can set the permissions. I'm Honestly not off the top of my head. I don't remember exactly what they're supposed to be but Typically when you go to like a go daddy or a host gate or one of those The permissions are pretty much already set for you. So you don't really have to worry about that too much Um, but just never do that prod. I do this in dev Just because I get sick of dealing with permissions issues and all that garbage. So We are going to now go into whoops here We're going to open our project And we want to just open blogger and First thing we really want to do here is get our database connection up and going You know, it's not set to root a security violation. Do you not do that? Blobber no, it's not blobber. It's blogger Actually a better double check that I don't remember what I named that. It's capital B. Not a lower case So we don't want to connect as root. That's massive security violations So we want to go in here and we want to actually add a user And see there's our pet store user right here We're going to add an account. We're going to call this blogger web Give it an ultra secure Password here Once again, never do that in prod. This is strictly dev This website will never live outside of my machine So we've got blogger If you're wondering what that percent sign is it's for host matching What hosts can connect to this thing typically in a prod you'll never do this This is all done on the back and you'll use cPanel or something like that Which I may actually do a cPanel tutorial sometime in the future, but All right, so we want to grab that username And we want to whoops want to put our ultra secure password in there Save that and I'm really happy that they split this up in the yee 1.1 This was all one giant config So every time you went from dev to prod you had to modify your config. It was a royal pain in the butt All right, so we've got that Let me Grab this little guy And where's blogger? I'm not seeing him here Up way at the bottom All right, so we're going to go to web and ta-da. There's our little Our website and all its glory so far and we've got our little You know yee debugging bar down here And we're going to just click about and then we're going to go to g because why not And we want to actually generate our models. So access denied. What is this? Hmm access denied See some you guys some of you folks love it when I do these in real time But it's a royal pain because then I got to figure out what I did wrong here Count limits. I bet I know what I did wrong. We're missing our administrative roles We're just going to say why am you can do everything? Why not? And I'm going to just verify with this Schema privileges. What what did I do there? Hmm. I'm not an expert in my sequel and I'm wondering why this is here But it's not here. Let's try add entry Let's try all schema. Why not? Let's just give it everything because we're in dev And I want to be able to do every little nick and create anything even though this is a massive security violation We could have very easily just you know Checked all but why not? All right, so we're in dev. We want everything Once again, don't do that in prod follow the official hardening guide for servers if you're going to do anything in prod Okay, we're going to go back here Magically it works All right, so I think that's why some people like it when I do these in real time because you'll be at home And you'll try doing what I do and you go well, I got this error message and you got to google it All right, so we're just going to generate some models here We're putting in star if that is very tiny. It's asterisk. It's just shift eight It's the wild card And then we're going to go preview And voila, there's our three beautiful models here. We're going to generate Notice how it's successful if you skipped the Change on and change mode In the very beginning of this you're probably going to get an access denied Or read write violation or something along those lines So we'll go back out to our beautiful little website here And ta-da, there's our models. I always like to go in and verify Um, I don't know if it's specific to the version that I was using But there was a bug in e2 where it was not doing my relations for some reason And it would just drove me crazy because I had to go in there and put them in myself So I always kind of if you see it has one or has many then you know, you're good All right, we got our user model. We're going to actually Inherit that this is how we would actually log in with ye, which is in a future tutorial So we're going to Let me check the time here. Um, u2 gets kind of cranky when I go over a certain time limit Okay, I think we're good for now. Um, let's go ahead and generate some crud here app models accounts Yep, forgot that Still pulling up all the stuff from the pet shop that we had. All right, so Now we're going to just generate our accounts here. Then what do we want? Categories My only real pet peeve about u2 is that you got to do the full path It's not like he won where you could just put a name and it would figure everything out for you Oh, yep, it's already complaining I'm guessing it's category not categories And we're just going to generate that and then Was our other table. I think it was just blogs. Yeah, it's blogs And we're going to generate that There we go And we're just going to go out to our website here. I'm already in the website derp And we're going to go here. We're just going to create a route and we're going to go blogs All right, so that's there. Let's look at accounts. We're going to heavily modify accounts in the future tutorial Because obviously every user doesn't want to see accounts And then what was the other one category? So We have now successfully created all our models all our crud our basic web structure connected to the database And well set permissions incorrectly. I might add never do that in prod You just like tattoo that on the back your hand never do that in prod All right, so I think that's going to be it for this tutorial future tutorials We're going to really dive into this thing really deeply and we're going to just We're going to build a website So I'm going to put this on the screen just as kind of a lasting image This is kind of the direction I'm taking I look forward to your feedback here though So if you see something missing or if you say hey, you know, let's you know do this before that. Let me know either via email or preferably in the void realms facebook group If you go to void realms you go to contact there's a facebook group with I think I lost count of how many people we got in there lots hundred literally hundreds of programmers in there from all different languages They just help each other out. So That's kind of creepy where it's like cutting my face off, but whatever So thank you for watching. I hope you found this educational and entertaining and uh, let me know