Introducing Laravel Breeze0:00
Okay, let's take a look at Breeze. Breeze is a minimal and simple starting point for your auth scaffolding in Laravel. It's a lightweight version of JetStream, it's easily customizable, and even includes tests. It makes use of Blade and Blade components, Tailwind CSS for styling, and even some Alpine JS for JavaScript. Let's go ahead and install it and take a look around. So as always, I have a fresh Laravel 8 app here, and all I've done is migrate the database. So let's go ahead and install this using Composer. So as you see, it's a dev dependency. So let's run that.
Installing Breeze0:34
So as you see, it's a dev dependency. So let's run that. Okay, that's done. And now all we have to do is run the Breeze install command. And what this is going to do is publish everything you need for authentication into our project. So actually, before I do that, let me just make this a git repo. And it's git add everything, and it's git commit, and say install Laravel, just so we can see the diff of what the Breeze install command does. So now I can run this. And it's saying to npm install and npm run dev.
Running and Verifying Setup1:06
So now I can run this. And it's saying to npm install and npm run dev. And that's just to install Tailwind and AlpineJS as well. So let's do that. Okay, that's done. Let's take a look at what it created here. Or let's take a look at our project first, let's refresh. And now you can see the login and register links. So let's just make sure this works. Let's register a new User here.
So let's just make sure this works. Let's register a new User here. And everything should work as expected, we're logged in and here is the minimal dashboard. So like I said, this publishes everything to your project directory. So you have access to everything and you can customize it however you like. So if you look at the diff here, you'll see here are all the controllers for your auth logic, some scaffolding for Tailwind here, here are all your views, including Blade components, and some modifications to your routes, and some tests here. So since everything is published, you can actually, if you want, go into your composer.json and actually delete the breeze dependency, because everything has been published and
Touring Published Structure2:12
So since everything is published, you can actually, if you want, go into your composer.json and actually delete the breeze dependency, because everything has been published and should work fine. But we'll just leave it. And let's take a look at our routes file here. So routes/web.php, you'll see that it added this dashboard here behind the auth middleware. But everything that's related to auth is within this auth.php, which is right here. And you can see the associated controller and middleware with all of these routes. So the controllers are located in app/Http/Controllers/Auth, and they're all here. And the views are located in resources/views/auth.
So the controllers are located in app/Http/Controllers/Auth, and they're all here. And the views are located in resources/views/Auth. And here they are. And the components are located within the components folder. So again, everything is available to you, you can modify these however you like. So for example, if you don't want to use Tailwind, go ahead and swap out the classes with either your own CSS, or if you want to make use of another CSS framework like Bootstrap, you can do that here as you have access to every single view. Like I said, it does make use of Alpine. So if you take a look at app.js, here is the require statement for Alpine.
Like I said, it does make use of Alpine. So if you take a look at app.js, here is the require statement for Alpine. And if you look at package.json, you'll see that it's included as a dependency as well. And the only place that it's used is within this drop down here. So we can show and hide it. So that is within, I believe there's a layout here. And if you look at navigation, and if you go up here, you'll see that we have this X-dropdown blade component, which should be in here. And here you can see the state for showing and hiding the drop down and the transition here, which also makes use of Tailwind CSS.
Customizing Registration and Login4:05
And here you can see the state for showing and hiding the drop down and the transition here, which also makes use of Tailwind CSS. So again, if you don't want to use that, you can go ahead and swap it out with whatever you want to use. So let's quickly go over how we could do something like that. So let's start with the register view. So this is most likely the thing that you'll modify. For example, if you wanted to add a new field here, you would do that. So again, the view is available to you here. So this should be register.
So again, the view is available to you here. So this should be register. You can add a new field here. And then the controller. Again, if you take a look at Auth is RegisteredUserController store. So we can go to that and store is right here. So just to show you that this is the method you can modify, if you like, it's dd here and let's see if it hits that. So let's just fill this out and we should hit that dd and we do. So same thing applies for logging in.
So let's just fill this out and we should hit that DynDump and we do. So same thing applies for logging in. Let's take a look at the routes file again. So logging in hits this AuthenticatedSessionController. So right here. And it's the store method. So right here. And as you see, it's calling this authenticate method, which is on the request. But this is a custom login request, which you can find in requests, LoginRequest and authenticate is right here.
But this is a custom login request, which you can find in requests, LoginRequest and authenticate is right here. And you can see there's some stuff with rate limiting here. Again, you can modify this however you like, or you can make your modifications to the controller directly. So yeah, very straightforward, even easier than what we had before in Laravel UI, where you had to override a trait or a method on a trait. And I don't think I mentioned it, but it does have support for forgetting your password or sending the reset link for forgetting password. So that would be within there should be a link within login, forget your password, enter
Running Included Feature Tests6:10
or sending the reset link for forgetting password. So that would be within there should be a link within login, forget your password, enter your email here, and then it should send a reset link where you can update your password. So again, all of that is within the published views and controllers. So you can modify that accordingly. So another thing which I really like is the fact that it includes a bunch of feature tests. So if you go down to tests, Feature, you'll see a bunch of new tests for testing the authentication. So you can just read through them to see what features it has. It's pretty self explanatory. And let's go ahead and run these tests.
It's pretty self explanatory. And let's go ahead and run these tests. So let me just update my phpunit and use SQLite here. And if I run phpunit, these tests should run and pass. So there you go. If you decide to modify the off scaffolding and want to make sure you didn't break anything, then go ahead and run these tests. So yeah, a quick overview of the simplicity of Breeze and how easy it is to customize. I personally really like it and will be making heavy use of it as someone who needs to create a bunch of demo projects for tutorials.
