User authentication is always a challenging part of any application. But, if you are using Laravel then no need to worry. There are lots of packages are available in Laravel for authentication. After releasing the Laravel 8, one most powerful feature has been added for authentication. The package is Jetstream. You can use Jetstream with Livewire and Jetstream with Inertia Js. Jetstream provides complete authentication for the user with lots of other functionalities. These are the advanced features added by the Laravel team inside the Jetstream. People did lots of comments regarding this awesome feature that they are not able to use all these functionalities in the same package. So, Taylor Otwell introduced the Laravel Breeze package for authentication. This is pretty clean and simple to use.
If you don’t want to use the Jetstream authentication then you can go with the Laravel Breeze. In this tutorial, I will be showing you the authentication using the Laravel Breeze auth package.
Prerequisites
For creating this Laravel 8 project you will require to have the following configuration.
- PHP >= 7.3
- MySQL (version > 5)
- Apache/Nginx Server
- VS Code Editor
- Composer
I assume that you are ready with the above tools. Now, let’s create the project.
Create New Project For Laravel Breeze
For installing the Laravel 8, I am using composer. You can go with the Laravel installer too. Open the terminal or command prompt and hit the below command.
After creating the project let’s create a database and then configure it for the application.
Create and Configure MySQL Database For Laravel Breeze Auth
For the database, I am using here MySQL. So, using command line, I just created the database using the below command.
CREATE DATABASE laravel8_breeze;
Now, we can connect the database with Laravel project. Hence, for the database configuration, just open the .env file of the Laravel project. Then, add the database details as showing below.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel8_breeze
DB_USERNAME=root
DB_PASSWORD=root
Here, I have put the database credentials. You will just require to replace the above credentials with yours.
Next, you will require to migrate the database. So, that all the necessary tables will be created inside the database.
php artisan migrate
Here, the tables are migrated into the database. Now, we can move for the installation step of Laravel Breeze package.
Install Laravel Breeze Auth Package
For installing the authentication package of Laravel Breeze, you have to navigate inside the project directory. Then simply hit the below command.
composer require laravel/breeze --dev
The above command will install the Laravel breeze authentication package.
Before using the authentication, it requires publishing the necessary components and much more things. Hence, in the next step, you have to run the install command. It will generate the authentication scaffolding.
php artisan breeze:install
This command publishes the authentication views, routes, controllers, and other resources to your application. Laravel Breeze publishes all of its code to your application so that you have full control and visibility over its features and implementation.
In the next step, it is asking to install npm. So, let’s follow the guide.
npm install && npm run --dev
The above command will install npm and then it will compile the css and js file.
After compiling the CSS and js file, you can see the result by running the application.
Breeze Auth Package Features
Just like the Laravel UI auth package, this auth scaffolding package provides the Register, Login, Forgot Password functionalities. But the difference is it comes with Tailwind CSS instead of Bootstrap. But, you can customize and use your own class. Also, you can use Bootstrap for the layout designs.
So, let’s start with the User Register functionality. Here, the Tailwind CSS provides a beautiful design. For the form elements, there are separate components.
If you navigate to the project directory then inside the resources/views folder you can see the components folder.
Here, for every element, there is a separate component. So, overall the form has been created through these components. That is the special feature of this package.
Breeze Auth User Register
You can easily register a new account by filling the required details. Here, below is the register page.
Here the form validations are added by default.
Fill up the details and create a new account here. After the successful registration, you will be redirected to the dashboard page.
Here, in the dashboard, you can see the basic and clean layout design. It is a little similar to the Jetstream layout. In the top-right dropdown, there is an option to logout.
Breeze Auth Login
After the logout, you will be redirected to the login page. Here, below is the login page. After the login, it will redirect again to the dashboard.
Breeze Auth Password Reset
There is the forgot password option. When you will click on that, you will have the below page. Here, you can enter your email to get the password reset link.
The password reset link work only when you have configured the email settings. Once you are done with the configuration, you will get the password reset link. By going through that link, you will be able to change the password.
Conclusion
Laravel 8 provided the Breeze Auth package for the user authentication scaffolding. This package is quite simple and clean than the Jetstream. So, you can use it easily in your Laravel application. Also, the UI is totally managed by the Tailwind CSS. But, it is fully under control. You can manage the design by your own class like Bootstrap. So, it is totally up to you. I hope you will enjoy this post. Thank you.
Leave a Reply