Blog Details

Laravel Breeze Folder Structure

In the previous post, we installed Laravel Breeze and created a working authentication system with login and registration.

But before we customize anything, it’s important to understand the files Breeze generated.

👉 In this guide, we’ll break down the Laravel Breeze folder structure:

  • Routes

  • Controllers

  • Views

  • Migrations

  • Middleware


Laravel Breeze Folder Structure

After installing Breeze, your project has new files like this

breezeauth/
├── app/
│   ├── Http/
│   │   ├── Controllers/
│   │   │   └── Auth/          ← Authentication controllers
│   │   └── Middleware/
│   └── Models/
│       └── User.php           ← User model
├── routes/
│   ├── web.php
│   └── auth.php               ← Authentication routes
├── resources/
│   └── views/
│       ├── auth/              ← Auth Blade templates
│       ├── layouts/           ← Layout Blade files
│       └── dashboard.blade.php
├── database/
│   └── migrations/            ← User & password tables
└── ...

1. Routes — routes/web.php & routes/auth.php

routes/web.php
Holds general app routes. Example:

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

require __DIR__.'/auth.php';

routes/auth.php
Holds all authentication routes like login, register, password reset. Example:

Route::get('/login', [AuthenticatedSessionController::class, 'create'])
    ->name('login');
Route::post('/login', [AuthenticatedSessionController::class, 'store']);

Route::middleware('auth')->group(function () {
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
    ->name('logout');
});

2. Controllers — app/Http/Controllers/Auth/

Each controller handles a specific part of authentication:

  • RegisteredUserController.php → Handles user registration.

  • AuthenticatedSessionController.php → Handles login/logout.

  • PasswordResetLinkController.php → Sends reset password link.

  • NewPasswordController.php → Updates password after reset.

  • EmailVerificationNotificationController.php → Sends verification email.

  • VerifyEmailController.php → Confirms user email.

📌 Why this matters: Each file is small and focused — easier to customize later.


 3. Models — app/Models/User.php

The User model is where user data lives.

By default, it includes:

protected $fillable = [ 'name', 'email', 'password', ];

👉 You can extend this with custom fields like username or phone_number (we’ll cover this in the next post).


4. Views — resources/views/auth/

Breeze ships with ready-made Blade templates for authentication:

  • login.blade.php → Login form

  • register.blade.php → Registration form

  • forgot-password.blade.php → Request password reset

  • reset-password.blade.php → New password form

  • verify-email.blade.php → Email verification

It also includes:

  • layouts/app.blade.php → Base layout with Tailwind CSS

  • dashboard.blade.php → Example logged-in page

📌 These files are fully customizable (UI + validation messages).


5. Database Migrations — database/migrations/

When you ran php artisan migrate, Breeze created:

  • users table → stores registered users

  • password_resets table → stores reset tokens

  • personal_access_tokens table → for API authentication (via Sanctum, optional)

👉 You can add extra columns (like role or profile picture) by editing the users migration.


6. Middleware

Laravel Breeze uses these middlewares:

  • auth → Only logged-in users can access certain routes.

  • guest → Only logged-out users can see login/register pages.

  • verified → Ensures user verifies email before accessing protected routes.

Example:

Route::get('/dashboard', function () { return view('dashboard'); })->middleware(['auth', 'verified']);

🔄 How Breeze Works (Step by Step)

  1. User visits /register.

  2. Route in auth.php points to RegisteredUserController@store.

  3. Controller validates data → creates user → logs them in.

  4. Redirects to /dashboard.

  5. Middleware checks authentication & email verification.


📚 Conclusion

Laravel Breeze may look minimal, but it generates a complete authentication system with:

  • Organized routes

  • Focused controllers

  • Ready-made Blade views

  • User migrations

  • Middleware protection

👉 In the next post, we’ll customize Breeze by adding new registration fields (like username and phone).

Leave A Reply

Your email address will not be published. Required fields are marked