📅  最后修改于: 2023-12-03 15:17:12.120000             🧑  作者: Mango
Laravel Artisan Auth is a command provided by Laravel that generates authentication resources for our application. Laravel Artisan Auth command is helpful when we want to quickly set up user authentication in our application.
To use Laravel Artisan Auth, open up your terminal and navigate to your Laravel application. Then use the php artisan
command followed by the auth
option. It creates necessary files and tables for authentication.
# Generate authentication resources
php artisan auth
# Generate authentication resources with views
php artisan auth --views
The above command will generate authentication resources such as routes, controllers, middleware, policies, and views.
The auth
command also supports arguments to specify more customized authentication resources.
# Generate only registration routes and views
php artisan auth --only=register --views
# Exclude routes, views
php artisan auth --except=reset-passwords
Below are the authentication resources generated by Laravel Artisan Auth.
Laravel Artisan Auth generates routes that handle authentication and password reset requests. These routes can be found in the routes/auth.php
file.
Laravel Artisan Auth generates two controllers, LoginController
and RegisterController
, that handle login and registration requests respectively. These controllers can be found in the app/Http/Controllers/Auth
directory.
Laravel Artisan Auth generates middleware that protect authenticated routes and ensure the user is a guest. These middleware can be found in the app/Http/Middleware
directory.
Laravel Artisan Auth generates policies that define authorization rules for the authentication resources generated. These policies can be found in the app/Policies
directory.
Laravel Artisan Auth generates views for authentication and password reset forms. These views can be found in the resources/views/auth
directory.
Laravel Artisan Auth is a powerful command that helps us quickly set up authentication resources in our Laravel application. With just a few commands, we can create routes, controllers, middleware, policies, and views that handle authentication and password reset requests.