Inspect Jetstream Routes0:00
Okay, let's take a look at how we can customize our Jetstream routes. Now, if we do php artisan route:list, you'll see a bunch of routes here that Jetstream and also Fortify generates. Now if you look at our code, and if we go into the routes file, none of those routes are in here. So they're actually loaded in the package directory, so within vendor, laravel/jetstream, and you can see the routes here. Now if you go into the JetstreamServiceProvider, which is right here, you'll see that it's loaded in this configureRoutes method, in the boot method.
Publish Jetstream Routes0:38
loaded in this configureRoutes, where is it? Right here, configureRoutes method, in the boot method. So if we go to that method, and we dump something in here, just to see it being loaded, let's say Jetstream routes from vendor folder, then that should be reflected when we go into our app here, okay? So there is an option to publish the routes, if we do php artisan vendor:publish, then we should get a list, and the one we're interested in is 21, which is Jetstream routes, so let's publish those, and you'll see that the routes were copied to routes/jetstream. However, all that did was copy the file over, and we're still not loading these routes. So just to prove to you that we're not loading them, let's go into that file in our project.
Ignore Vendor Routes1:28
However, all that did was copy the file over, and we're still not loading these routes. So just to prove to you that we're not loading them, let's go into that file in our project directory, so right here, and let's just dump Jetstream routes from project file, or project routes file, and we won't see that in our app here, okay? So what we want to do is ignore the routes from the vendor directory, and load the ones in from our project, so let's go ahead and do that. So let's open up the JetstreamServiceProvider, not to be confused with the one in the project, or in the package folder, but the one in our app here, so app, providers, JetstreamServiceProvider, and within the register method right here, we can ignore the routes. So we can do Jetstream::ignoreRoutes(); okay?
Load Project Jetstream Routes2:17
provider, and within the register method right here, we can ignore the routes. So we can do Jetstream, ignore routes, okay? And now, if I reload this page, we will no longer see this message, okay? And we also get an error because the routes are not defined anymore. So what we can do is do the same thing that this other service provider does, and load the routes. So we can grab this, put it within our Jetstream provider, in the boot method, actually let's call configureRoutes down here, so this configureRoutes, and let's make that method, actually let me just copy it from here, the whole thing, okay? And let's paste that in.
let me just copy it from here, the whole thing, okay? And let's paste that in. So let's get rid of the conditional here, since we do want to load the routes, and let's dump Jetstream routes from app folder, and let's re-indent this, and let's just make one change here, instead of from here, I am going to use the base path helper method, and load the routes from routes/jetstream.php, and that should do it. Now if I reload this page, route not found, so let's import that, okay, reload, and now we get the two dumps because I also have the other dump in the routes file, but we can get rid of this because we now know that we're using the routes in our project, and let's go in here, let's get rid of this, and just to make sure that we can modify the routes,
Customize Fortify Routes4:05
get rid of this because we now know that we're using the routes in our project, and let's go in here, let's get rid of this, and just to make sure that we can modify the routes, let's change the route signature here, and it should be, or this should be changed now, and you see the extra ease there, okay, and one more check to make sure the original routes are not being loaded, this should result in a 404, and it does. Okay so let me put this back, so you now have full control over your routes here if you want to do anything, or make any modifications here. So let's do the same thing for the Fortify routes, so let me just reload this, and let me log out here, so say for example you wanted to change the route for login, and change it to sign in, so same process here, so the routes are being loaded in the Fortify service.
me log out here, so say for example you wanted to change the route for login, and change it to sign in, so same process here, so the routes are being loaded in the Fortify ServiceProvider within the vendor folder, so let's look for that, Fortify, the routes are right here, and the ServiceProvider is right here. So let's do the same thing, let me grab the configureRoutes method, okay, let's go into the Fortify ServiceProvider in our app, right here, let's ignore the original routes, Fortify ignore routes, okay, let's call that configureRoutes method down here, this configureRoutes, let's paste that in, let's get rid of the conditional here, let's re-indent, let's import Route, and now if we look at the publish command here, you'll see that there's no option for the Fortify routes, so we have to do it manually.
Manually Copy Fortify Routes5:58
route, and now if we look at the publish command here, you'll see that there's no option for the Fortify routes, so we have to do it manually. So let's make a new file here called Fortify, okay, and let's grab those routes from the vendor directory, right here, I'm just gonna grab all of this, copy that, and paste it into our Fortify routes here, okay, and now I still think I have to make some modifications here. Yeah, let's just change this to base_path, base_path routes slash Fortify.php, okay, so let's see if this works, let's go into our routes file, our modified one, and let's see if we can change login to sign_in here, okay, and this is the correct one, right, yeah, this is the correct one, the one in our project, and let's see if this works,
