laravel 5.3新添加了Auth::routes()。
laravel 5.3新添加了Auth::routes()。
最近我开始使用laravel 5.3写博客,但是在运行php artisan make:auth
之后有一个问题。
当我运行它时,它会生成我的web.php
中的路线。
这是它里面的代码:
Auth::routes(); Route::get('/home', 'HomeController@index');
然后我运行php artisan route:list
,我发现有很多动作,比如LoginController@login……
但是我在App\\Http\\Controllers\\Auth
中没找到这些动作,他们在哪里?
还有,Auth::routes()
是什么意思,我找不到有关Auth的路由。
我需要有人帮助,谢谢您回答我的问题。
admin 更改状态以发布 2023年5月21日
这里是Laravel 5.7、Laravel 5.8、Laravel 6.0、Laravel 7.0和Laravel 8.0(请注意6.0中电子邮件验证路由的小变化)。
// 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');
您可以在此验证这些路由:
- v5.7 https://github.com/laravel/framework/blob/5.7/src/Illuminate/Routing/Router.php#L1176
- v5.8 https://github.com/laravel/framework/blob/5.8/src/Illuminate/Routing/Router.php#L1151
- v6.0 https://github.com/laravel/framework/blob/6.x/src/Illuminate/Routing/Router.php#L1178
- v7.0 https://github.com/laravel/ui/blob/2.x/src/AuthRouteMethods.php(已移到laravel/ui包中)
- v8.0 https://github.com/laravel/ui/blob/3.x/src/AuthRouteMethods.php(除添加可选命名空间外没有更改)
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');