laravel 5.3 新授权::routes()

2022-08-30 06:51:21

最近我开始使用laravel 5.3写博客,但我在运行后有一个问题php artisan make:auth

当我运行这个时,它会在我的web.php

这是其中的代码:

Auth::routes();

Route::get('/home', 'HomeController@index');

然后我跑了,我发现很多动作,比如LoginController@login...php artisan route:list

但是我没有在我的中找到这些动作,这些在哪里?App\Http\Controllers\Auth

还有代表什么,我找不到关于Auth的路线。Auth::routes()

我需要别人的帮助,谢谢你回答我的问题


答案 1

Auth::routes()只是一个帮助程序类,可帮助您生成用户身份验证所需的所有路由。您可以在此处浏览代码 https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php

这是路线

// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');

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

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

答案 2

这里是 Laravel 5.7Laravel 5.8Laravel 6.0Laravel 7.0Laravel 8.0(请注意 6.0 中对电子邮件验证路由的 bc 稍有更改)。

// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');

// Confirm Password (added in v6.2)
Route::get('password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('password.confirm');
Route::post('password/confirm', 'Auth\ConfirmPasswordController@confirm');

// Email Verification Routes...
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify'); // v6.x
/* Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify'); // v5.x */
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');

您可以在此处验证这些路由:


推荐