How To Use Laravel Breeze For Authentication?

0
613
Laravel Breeze For Authentication

Laravel 8 introduced two new authentication starter kits, breeze, and jetstream. In Laravel 6 and 7, you needed a package called laravel/ui to scaffold authentication. And even in earlier versions, like laravel 5 or 4, you need make:auth command. In this tutorial, you will learn how to use the laravel breeze for authentication.

# Installing Laravel 8

In the first place, you need to install the Laravel framework. Laravel version 8 is necessary to use Laravel breeze. Also, a minimum PHP version 7.3.0 is required to install Laravel 8. Use the following commands to install laravel 8. Also, it will start your development server at https://localhost:8000.

composer create-project laravel/laravel breeze "8.*"
cd breeze
php artisan serve

# Configure Database

After installing laravel, configure the database in your .env file. After that, migrate the database.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=breeze
DB_USERNAME=root
DB_PASSWORD=
php artisan migrate

# Configure Laravel Breeze For Authentication

As discussed, the jetstream starter kit provides more advanced functionality. On the other hand, the Breeze starter kit provides minimal but similar functionalities. Moreover, breeze authentication pages are powered by Tailwind CSS. Keep in mind, if you want to use two-factor authentication, or Livewire, choose Jetstream over Breeze.

# Installing Composer Dependency

Firstly, install the laravel/breeze package using the following command.

composer require laravel/breeze --dev

Secondly, use the breeze:install artisan command. It’ll create views, routes, controllers for authentication.

php artisan breeze:install

Importantly, you may compile your assets using the npm command. This command will install Tailwind CSS and other necessary packages.

npm install
npm run dev

Finally, navigate your login or register route. To see routes visit routes > auth.php. Breeze defines all routes in that file. As a result, you will see the Tailwind powered pages as below. Signing up a user will give you a beautiful dashboard page.

Laravel Breeze Tailwind CSS Login
Laravel Breeze Dashboard

# Conclusion

Sometimes, you might get an error that says, “PostCSS plugin tailwindcss requires PostCSS 8”. This error might occur while compiling assets. It’s nothing but just a version compatibility issue of Tailwind CSS. In this case, use the following commands.

npm uninstall tailwindcss postcss autoprefixer
npm install tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9

I hope you learned laravel breeze for authentication in this tutorial. Please support by sharing this article. Thankyou for reading. 🙂

Learn more about Laravel Framework

Previous articleLaravel Stripe Payment Gateway Integration
Next articleHow to use react useEffect hook?
Welcome to the world of web development, where technology and creativity come together to bring ideas to life. My name is Keyur Gadher, and as a web development blogger, I am here to share my knowledge and experience with you. From front-end web development to back-end programming, I will provide you with valuable tips, tricks, and techniques to help you create beautiful and functional websites that are tailored to your specific needs. Whether you're a beginner or a seasoned pro, I am here to help you take your web development skills to the next level. Join me today and let's start coding!

LEAVE A REPLY

Please enter your comment!
Please enter your name here