laravel 5.3 new Auth :: routes()

时间:2016-08-29 00:13:57

标签: php laravel laravel-5 laravel-5.3

最近我开始使用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的路线。

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

11 个答案:

答案 0 :(得分:165)

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');

答案 1 :(得分:43)

为Laravel 5.3验证路由而不是Auth :: routes()。 我希望它有所帮助...

Route::group(['middleware' => ['web']], function() {

// Login Routes...
    Route::get('login', ['as' => 'login', 'uses' => 'Auth\LoginController@showLoginForm']);
    Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\LoginController@login']);
    Route::post('logout', ['as' => 'logout', 'uses' => 'Auth\LoginController@logout']);

// Registration Routes...
    Route::get('register', ['as' => 'register', 'uses' => 'Auth\RegisterController@showRegistrationForm']);
    Route::post('register', ['as' => 'register.post', 'uses' => 'Auth\RegisterController@register']);

// Password Reset Routes...
    Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm']);
    Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail']);
    Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\ResetPasswordController@showResetForm']);
    Route::post('password/reset', ['as' => 'password.reset.post', 'uses' => 'Auth\ResetPasswordController@reset']);
});

因此,如果您更改这些路线的某些名称,请记住同时更改帖子的操作!

答案 2 :(得分:18)

如果要同时添加 Laravel 5.7 Laravel 5.8 (无更改),包括验证路径

>
// 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');

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

您可以在此处验证以下路线:

答案 3 :(得分:14)

Laravel 5.5.x

// 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')->name('password.request');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');

答案 4 :(得分:7)

函数调用顺序:

  1. (AUTH)照亮\支持\外墙\验证@路由 (https://github.com/laravel/framework/blob/5.3/src/Illuminate/Support/Facades/Auth.php
  2. (应用程序)提供照明\基金会\应用@ AUTH
  3. (路线)照亮\路由\路由器
  4. 这样的路线:

    Public Class frm_DBSolventes
    
    End Class
    

答案 5 :(得分:6)

这对我有用 Laravel 5.6

在文件web.php中,只需替换:

Auth::routes();

人:

//Auth::routes();
// Authentication Routes...
Route::get('admin/login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('admin/login', 'Auth\LoginController@login');
Route::post('admin/logout', 'Auth\LoginController@logout')->name('logout');
// 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');

并删除以下两个文件中的注册链接:

welcome.blade.php
layouts/app.blade.php

答案 6 :(得分:4)

如果您在laravel 7版本的这些相同路线中搜索,则会在 $missings = []; $matches = false; for ( $i = 0; $i < count($tagarray); $i++ ) { $matches = false; for ($e = 0; $e < count($tag); $e++ ) { if ( $tagarray[$i] == $tag[$e] ) $matches = true; } if(!$matches) array_push($missings,$tagarray[$i]); } dd($missings);

中找到它

答案 7 :(得分:0)

loginuser类使用名为AuthenticatesUsers

的特征

如果打开该特性,您将看到这些功能(这适用于其他控制器) Illuminate\Foundation\Auth\AuthenticatesUsers;

这是特征代码https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php

抱歉格式不好,我正在使用手机

Auth::routes()它只调用一个返回auth路由的函数(我认为)

答案 8 :(得分:0)

我很惊讶没有人提到命令php artisan route:list,该命令给出了所有已注册应用程序路由的列表(如果已注册,则包括Auth::routes()Passport::routes()

答案 9 :(得分:0)

如果您在web.php中的laravel 5.7及更高版本Auth::routes(['register' => false]);

更多可能的选项如下:

Auth::routes([
  'register' => false, // Routes of Registration
  'reset' => false,    // Routes of Password Reset
  'verify' => false,   // Routes of Email Verification
]);

答案 10 :(得分:0)

对于 Laravel 8:

all_combinations = []
for i in range(1, len(feature_cols) + 1):
    for combo in itertools.combinations(feature_cols, i):
        all_combinations.append(combo)