Laravel Breeze is a minimalistic package for Laravel 8+ that provides a basic authentication system for your web application. With the release of Laravel 8, Laravel Breeze has been introduced. This package comes with some additional features and improvements in terms of authentication. The other interesting thing is this package is managed by the Laravel community itself like others. So, you can say this is not a third-party package and this is more reliable and secure as well. This is more featured in comparison to Laravel UI auth. Also, the layouts and UI are totally improvised. If you have a basic requirement of managing auth for users then definitely, you can go with this package in Laravel. In this blog post, we will take a look at Laravel 10 Breeze auth and its new features.
You will have the authentication system using the Breeze package. Which provides Login and Register links in the homepage.
The Register form will have the below inputs by default.
After successful registration, it will redirect you to the Dashboard page.
Also, you will have the Profile and Logout option in the header profile action. You can manage and update the profile, and password details.
If you logout in the application then you will have the Login page. It will look like this.
We will see all these features in detail in this post. Therefore, let’s start diving into this.
Prerequisites
To implement Breeze auth in Laravel 10, you need a Laravel 10 application.
But, for having a Laravel 10 installation, the below tools and configurations are needed.
- PHP >=8.1
- Composer
- Apache/Nginx Server
- VS Code Editor (Optional)
- MySQL (version > 5)
We will be going up step by step in this post for having an authentication using Breeze auth in Laravel 10. But, before diving into it, let’s quickly go through the features of the Breeze Auth package.
Features of Laravel 10 Breeze Auth
We will be taking a look at the important features of the Laravel Breeze auth package.
- Social Authentication: Laravel 10 Breeze comes with built-in support for social authentication via Laravel Socialite. Now, you can easily add social authentication to your web application. However, you need to configure your social authentication providers in the
.env
file. Also, respectively, you need to update the authentication views. We will cover social authentication in upcoming posts. - Email Verification: Laravel Breeze packages now includes email verification functionality out of the box. When a new user registers, an email verification link is sent to their email address. Once the user clicks on the link, their account is verified. So, that they can log into the account.
- Password Confirmation: This package provides functionality for password confirmation. That means when users want to change their password. Users must confirm their current password before changing the new password.
- New Authentication Routes: Laravel 10 Breeze now includes new authentication routes. Such as /forgot-password and /reset-password. Which allows users to reset their passwords if they forget them.
- Updated Layout: The authentication views in Laravel 10 Breeze now come up with an updated layout. This includes a navigation bar and a footer.
Step 1 – Install Laravel 10 For Breeze Auth Implementation
You need to install Laravel 10 project setup at the very first step.
composer create-project --prefer-dist laravel/laravel auth-app
Once the installation is done, in the next step, you have to configure the database.
Step 2 – Configure Database Connection in Laravel
In this step, you have to create a database for the app. Then you need to connect it with the application as well. So, for the configuration, you need to navigate to the .env file and add the DB credentials as shown below.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE={{ DATABASE_NAME }}
DB_USERNAME={{ DATABASE_USERNAME }}
DB_PASSWORD={{ DATABASE_PASSWORD }}
Next, you need to install the Laravel Breeze package.
Step 3 – Install Laravel 10 Breeze Auth Package
For installing this package, you need to move ahead at the terminal. Then hit the below command.
composer require laravel/breeze --dev
This command will add the authentication package.
Wait, the authentication is not completed yet. That means we have more steps to complete that. We just added the package. However, the installation is missing now. So, let’s move to the next step in this example.
Step 4 – Install Laravel Breeze Auth in Laravel 10
In this step, we will install breeze auth scaffolding. As we are using Laravel 10, hence, it will prompt a few options to be installed in the command line.
php artisan breeze:install
So, just follow the instruction as shown below. We are going to install Laravel 10 Breeze auth for the blade authentication. But, it provides authentication for the components as well. Such are React and Vue.
After the successful installation, you will be able to see Auth links on the Laravel homepage.
Even you will be able to access the Login and Register pages as well. The interesting thing is the Breeze package installs npm dependencies automatically. That means, just like the Laravel UI package, you don’t need to install npm after adding auth scaffolding. This is basically an update in Laravel 10.
Let me show you.
But, still, we won’t be able to proceed with the Registration. Because we haven’t migrated the migration yet.
Step 5 – Migrate Schema in Laravel 10
For migrating the schema, you need to run the below artisan command.
php artisan migrate
Now, we have migrated the schema as shown below.
So, now, you are ready to use the authentication features in Laravel 10 using Laravel breeze auth.
Step 6 – Run the Application
At last, you have to run the application to see the result.
php artisan serve
Final Words
We have implemented Authentication in Laravel 10 using Laravel Breeze Auth. We saw it’s amazing features here. I am wrapping up this post. I hope you will enjoy this. For any kind of issue, don’t forget to write in the comment section. I will try to sort out as soon as possible.
Leave a Reply