Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BartHuis's avatar

Where does artisan make:auth set the routes?

Hi, I've done artisan make:auth, it all works, but where does it place his routes? I only see explanations on how to protect routes, but not where the routes of the auth itself are defined.

Bart

0 likes
8 replies
davidrushton's avatar
Level 5

That command puts the following in your routes.php file

Route::auth();

Which expands to the following if you look in vendor/laravel/framework/src/Illuminate/Routing/Router.php

/**
 * Register the typical authentication routes for an application.
 *
 * @return void
 */
public function auth()
{
    // Authentication Routes...
    $this->get('login', 'Auth\AuthController@showLoginForm');
    $this->post('login', 'Auth\AuthController@login');
    $this->get('logout', 'Auth\AuthController@logout');

    // Registration Routes...
    $this->get('register', 'Auth\AuthController@showRegistrationForm');
    $this->post('register', 'Auth\AuthController@register');

    // Password Reset Routes...
    $this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
    $this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
    $this->post('password/reset', 'Auth\PasswordController@reset');
}

Hope that helps!

2 likes
BartHuis's avatar

thnx, thats what i searched for, only asking myself, where is the link to that router? there's no use in the top of the routes file. would like to understand the flow between the app and vendor files to use things myself.

BartHuis's avatar

wait, i see it's the illuminate router, so that means the whole file is loaded, even when a part of illuminatie isn't used? :S

davidrushton's avatar

@BartHuis If I understand your question, you're asking how Route::auth() works in the routes.php file, without being imported?

Route is a Facade which is registered in your config/app.php to be available globally.

'aliases' => [
        ...
        'Route'     => Illuminate\Support\Facades\Route::class,
        ...
]

The facade class is linked to the router instance which is the Illuminate/Routing/Router.html class.

BartHuis's avatar

thanks, found that facades thing before... i'll give those a read :)

BartHuis's avatar

@davidrushton if i look closely at vendor/laravel/framework/src/Illuminate/Routing/Router.php it seems a bit strange to me that it has only functions at i would expect from this file, but there are also routes of the auth in it? :S what is the logic of adding only the auth routes in this file? :S

davidrushton's avatar

@BartHuis I believe the Route::auth() method is really just a helper to save you from writing all of those individual routes yourself. Also, since AuthController and PasswordController end up using core Laravel traits anyway, the benefit would be that possible changes to method names, etc, would be handled for you.

I end up writing my own Auth controller for projects, so I defined the routes myself anyway.

Hope that helps.

1 like
BartHuis's avatar

@davidrushton thanks, i can see the logic of including the routes in the core, but only not in that file :S

Please or to participate in this conversation.