Authentication with Laravel Breeze
Laravel Breeze provides a simple and lightweight authentication system, including login, registration, password reset, and email verification. It is the perfect starting point for Laravel authentication, especially for small to medium-sized projects.
Step 1: Install Laravel Breeze
First, make sure you have a Laravel project set up. If you don’t have one, create a new Laravel project:
Now, install Laravel Breeze via Composer:
Step 2: Install Breeze Authentication
Once Breeze is installed, you need to publish its authentication scaffolding:
You'll be prompted to choose between different stack options (Blade, Vue, React, etc.). The default option is Blade, but you can specify a frontend stack:
For other frontend stacks, use:
Step 3: Migrate the Database
Make sure if the .env
file is correctly configured for the database, then run the migrations:
Step 4: Install NPM Dependencies (For Tailwind CSS & JS Frameworks)
If you chose a frontend stack like Vue or React, install and compile assets:
If you're using Blade, this step is still recommended to build the Tailwind CSS styles.
Step 5: Start Your Laravel Development Server
Now, run the application:
Visit:
http://127.0.0.1:8000/register – Register page
http://127.0.0.1:8000/login – Login page
Step 6: Customize Authentication
Modify Authentication Views
Laravel Breeze stores authentication views in resources/views/auth/
. You can edit these files to customize the UI.
login.blade.php
– Login formregister.blade.php
– Registration formforgot-password.blade.php
– Password reset
Modify Authentication Routes
Breeze registers authentication routes in routes/auth.php
. You can modify them if needed.
Step 7: Protect Routes with Authentication Middleware
To secure certain routes, wrap them in the auth
middleware inside routes/web.php
:
This ensures only logged-in users can access the dashboard.
Conclusion
Laravel Breeze is a quick and efficient way to set up authentication in your Laravel application. It provides a simple scaffold that you can customize as needed. š
Would you like to extend Breeze with roles/permissions or integrate it with an API? š