Setting Up Authentication with php artisan make:auth
Nearly every application with user accounts needs the same core features: registration, login, logout, and password reset. Rather than building this from scratch, Laravel offers official starter kits that scaffold a complete, working authentication system in minutes.
How Laravel Scaffolds Authentication
Older Laravel versions offered a single make:auth command; current versions provide this functionality through official starter kits, installed as a separate package and then set up with an Artisan command. Regardless of the exact command, the result is the same: ready-to-use routes, controllers, and views for handling accounts.
What Gets Scaffolded
| Feature | What It Provides |
|---|---|
| Registration | A form and controller logic for creating new user accounts |
| Login / Logout | Session-based authentication for returning users |
| Password Reset | Email-based flow for recovering a forgotten password |
| Email Verification | Optional flow requiring a confirmed email before full access |
Why Use Scaffolding Instead of Building Manually
- Follows Laravel's security best practices by default, like password hashing
- Saves significant time compared to building each flow from scratch
- Provides a solid, working starting point that can be customized further
Scaffolding is the fastest path to authentication, but it's worth understanding what's happening underneath — which is exactly what manual login and registration logic reveals.
From make:auth to Today's Commands
The old php artisan make:auth command was removed from the framework core some time ago, so running it on a modern project simply reports that the command is not defined. Its replacements depend on the project:
| Situation | What to use |
|---|---|
| New project with the Laravel installer | Choose a starter kit (React, Vue or Livewire) when laravel new asks |
| Existing project using Blade views | Laravel Breeze, a lightweight kit with Blade templates |
| Older app that used Bootstrap views from make:auth | The laravel/ui package, which keeps the classic scaffolding |
| Need only the backend, with your own frontend | Laravel Fortify, which provides routes and logic without views |
Worked Example: Adding Breeze to a Project
Breeze is a good choice for learning, because every controller and view it creates is plain code you can read and change.
composer require laravel/breeze --dev
php artisan breeze:install blade
npm install
npm run dev
php artisan migrate
After the migration creates the users, password_reset_tokens and session tables, visit /register to create an account. Breeze also creates a dashboard route that only signed-in users can open. For the classic Bootstrap-style scaffolding instead, the equivalent commands are:
composer require laravel/ui
php artisan ui bootstrap --auth
npm install && npm run build
Check that the package version supports your Laravel version before installing, since starter kit options change between major releases.
Using Authentication in Your Own Code
Once scaffolding is in place, three tools cover most needs. Route middleware protects pages, the Auth facade gives you the current user, and Blade directives change what the page shows.
// routes/web.php
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/dashboard', fn () => view('dashboard'))->name('dashboard');
Route::get('/orders', [OrderController::class, 'index'])->name('orders');
});
// In a controller
$user = Auth::user(); // or $request->user()
$orders = $user->orders()->latest()->get();
{{-- In a Blade view --}}
@auth
<p>Welcome back, {{ auth()->user()->name }}</p>
@endauth
@guest
<a href="{{ route('login') }}">Log in</a>
@endguest
The verified middleware only works when the User model implements MustVerifyEmail, which turns on the email verification flow.
Things to Configure Before Going Live
- Mail settings: password reset and verification emails fail silently in testing if
MAIL_*values in.envare missing. Use a mail-testing tool locally. - Login throttling: the starter kits limit repeated failed logins; keep it enabled and tune it rather than removing it.
- HTTPS and secure cookies: serve the site over HTTPS and set session cookies as secure in production.
- Redirect paths: update where users land after login if your main page is not the dashboard.
- Password rules: use the
Passwordvalidation rule to require sensible length and complexity.
Common slips include forgetting php artisan migrate, forgetting the frontend build step so pages load without styling, and editing vendor files instead of the published controllers and views in your own app folder.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.