Laravel 9 Domain Driven Design Authentication - Part 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so first thing i want to give a shout out to the full stack network um this is a social network just built for uh developers who are trying to show off their work and just you know be their creative self to basically show the world what they can do and at the same time socialize so shout out to them and let's get started with this video [Music] all right so last we left off was uh installing kiln css now let's tackle uh our login and registration i know it's coming uh all the way at the stage four but i think it's more valuable to understand why i wanted to go to just reorganizing everything first and then adding starter kit because when you start overloading uh laravel itself it just becomes huge where you have issues then you know all the authentication and everything so so far um if you are interested in just stopping here and moving on you can install your own uh level package for authentication but i'm going to go ahead and start using level breeze for this series and the reason why is because i think level has an uh level breeze has an uh available authentication for api which is pretty enticing knowing that we're going to use larval inertia.js and for our front end and livewire for our back end i mean we could you can use either or but this makes a lot of sense unless if you're installing react or vue by itself so let's get started with this all right so first thing i'm going to do is just i'm going to copy this and bring it back to the code base so let's see all right and now if i have composer require level breeze and everything hopefully should go through and i'm aware of this error we'll go ahead and fix that sometime later but um it doesn't affect our current code base in any way shape or form so i'm going to say php artisan and see if breeze actually showed up here so let's see if i go back up yeah so we have breeze installed command already so i'm going to go back to the docs and just steal the api command again and then if i come back here i'm just going to install this and now your scaffolding is ready but before we move on to that i just want to show you what exactly changed because if you realize we have modified our own version but right here you have back-end um in front and now it deleted all that stuff so yes i understand but the fun part here is just reorganizing this i mean it's completely up to you how you want to look at everything but for me i think it just removes the js and uh back-end folder which is not a big deal we can restore these with our github with our git session so it wouldn't be a big deal but right here uh you see we have a web and api also it made some changes onto these which we're going to take a look at but moving forward now we know what it changes this way if you are following the series you should be able to come up with all these changes pretty easily and that way you don't have to go through all the hassle that i have to go through and also again you can fork this repo i'll share the link down below and then you can get started on your own so you don't have to go through everything all right so let's take care of first thing first all right so using the power of git uh what i'm gonna i'm gonna do is i'm gonna restore these files that get deleted so restore this uh restore my app.js bootstrap there you go this one and now uh let me see what else we need to work with so webpack it says it has removed webpack and maybe because it's thinking we don't have those so if i go back in there and put it back so if i go source control so we do want the package control so and the webpack so i'm going to keep all these that way we can we can take a look at it later hopefully everything works on the yarn side from what from our last episode but here as you can see uh everything works now and let's see what changed in composer.json file oh that's just uh adding the package level breeze so uh yeah we're going to start moving on and start changing the name spaces for these so let's get started with that so one thing i want to let you know that i remember how we created that home page it's not going to read that because it overrided our our routes file so it's just now just showing me the level version which is 9.12.2 at the at the moment and if we go back into our web and it's just going to show us this which is completely fine we can also just copy this command and go ahead and make those changes on our if i go back here source control and then rot file route web and then we can say restore my old one and import these routes right here and now as you guys can see everything should work fine so if i come back in here and we're back to square one so now let's see if it gives us uh some login routes yes and then register so this is what we have currently and we need to start fixing these namespaces and routing uh next all right so let's start looking at our controller so right here uh it generated odd controllers what i'm going to do is uh um so right now it has aut right here so i'm just going to move everything to a folder which is auth and all these need to go into controller folders so i'm going to generate a new folder controllers and then i just got to move these back into controllers so this way we have everything in one place uh next thing i'm going to delete this so there you go to trash and then it also has requests so what i'm going to do is i'm going to add a new folder and then request and here i'm just going to move login request right here so this way i can get rid of this as well as you see now my auth has its own domain and it has its own uh login requests where you can use this login request to log in your users now let's go ahead and start fixing namespaces so if i do controller so behind the scene what i'm going to do is i'm just going to fix all the name spaces for these i'll just do one with you guys so that way you guys understand so import class and input my original controller which is under app controllers and then fix the namespaces here so what i'm going to do is i'm going to copy from right here which is our namespace and then just make some changes quickly so here it's going to be odd instead of user so now if you see how easy and smooth it is you'll be surprised um what what this is gonna do for your code base okay so behind the scene let me do everything uh let me change everything and uh with the magic of editing uh get right back all right so while i was editing this i noticed that uh it's giving me an error for users so again this is going to import our user from the domain so right here the change will be made so now you have users right there so this will help but everything else looks good now now let's work towards our route service provider because i think this needs a little bit of editing if i go back into my route service provider so that's right there so in service provider route service provider currently it just refers to one constant which is home but if you remember from our previous videos where i went and created admin and user this is where it's going to help so what we can do is literally have two um two constants one would be our uh admin and we can send this traffic to admin i'm just gonna leave this as this as it is and then this would be user so here uh i'm going to say user so when you log in as a user it's going to land on a user dashboard and when you log in as an admin it's going to route you towards the admin all right so let's go ahead and start fixing uh route service provider so i'm gonna import these classes and service provider is here and now it's gonna error out so we can just say select this and user so if the user is verified then go ahead and send them off and again work i'm going to come back to these front-end urls and stuff like that which we're going to be fixing in the routing but uh everything else looks good let's just make sure everything looks good on this side there are no errors on all of these ah there you go that's another one so we can import this and then add user and the next thing would be maybe this one yeah so everything looks good let's go ahead and see and obviously it's going to fail because it's not going to understand what we're trying to do so let's go ahead and hit the register method again so obviously it doesn't have a get method or uh post method because we haven't fixed the routing yet so let's go ahead and fix that so r auth and right now it doesn't have anything which is fine uh if you go to the package itself actually you can find this under laravel breeze so stubs and then api routes so your odd routes are going to be right here so i already have these uh copied and pasted so let me just paste them all right so i'm going to go ahead and paste them right here uh so now as you can see i've imported all the route the author outs and then i've fixed the name namespaces uh in the back end so now if you go ahead and look at the register route it's going to say myapp controller register controller so it is not finding it and then let's go ahead and see what the issue is here so my app http right because we have the back end so sorry my bad i think i missed that so this one it's going to be backslash back in and now it should be able to see or locate those which is perfectly fine i know it's going to fail my app back in http i think that's it right uh http backend my bad okay oops so back in and then if i go back in there it should give me a different error which is good because now it's saying the method create hat doesn't have um you know it's it's facing some challenges what we're going to fix but so far so good everything uh looks amazing on on the back inside with the next part i'm going to show you how to start creating uh the views for the authentication that way you'll have a good idea um the video is getting more than 10 minutes so i i just i want to stop right here and upload a second video showing you how to do the uh the views for these and then you can add anything from there and then the next video i'm sorry i keep saying that uh teasing the live wire and inertia.js but i think these are necessary steps before uh we go there so uh it's a quite enjoyable time for me please go ahead and feel free to like this video share it with your friends i hope you enjoyed the video i've put in a lot of hard work on to producing these videos and i hope you're enjoying it thank you smash that like button take care
Info
Channel: Gurulabs
Views: 1,331
Rating: undefined out of 5
Keywords: laravel 9 domain driven development, ddd laravel 9, laravel, laravel 9, ddd, laravel 8, laravel project tutorial, laravel 9 tutorial, laravel tutorial, laravel project, livewire, domaindrivendevelopment, domain-driven, domaindrivenapplication, laravel tutorial for beginners step by step, php laravel youtube, domain driven design, what is domain driven design, microservice architecture pattern
Id: 6k-7ImKSyJs
Channel Id: undefined
Length: 12min 36sec (756 seconds)
Published: Fri May 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.