laravel Route::auth() 和命名空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34440177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Route::auth() and namespacing
提问by myol
I have used make:authto create the login scaffold which works nicely in the base app. However I am creating a package so I have moved the files to their respective places in my package.
我曾经make:auth创建过在基本应用程序中运行良好的登录脚手架。但是,我正在创建一个包,因此我已将文件移动到我包中的相应位置。
I have namespaced the route created by the make:authapp to
我已将make:auth应用程序创建的路由命名为
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/home', 'Package\Namespace\HomeController@index');
});
When I comment out Route::auth();everything seems to work fine. When I keep Route::authI get an error
当我注释掉Route::auth();一切似乎工作正常。当我保持时,Route::auth我收到一个错误
Class Auth\AuthController does not exist
I cannot understand what the issue is. I don't know much about the auth()helper function.
我无法理解问题是什么。我对auth()辅助函数了解不多。
回答by myol
Obvious error...
明显错误...
Within Router.phpthe auth()function namespaces are in relation to the default Controllersnamespace.
在Router.php该auth()功能的命名空间是相对于默认Controllers命名空间。
Removing the auth()function and adding all the namespaced routes into the routes file of course did the trick
删除该auth()功能并将所有命名空间路由添加到路由文件中当然可以解决问题
// Authentication Routes...
Route::get('login', 'App\Http\Controllers\Auth\AuthController@showLoginForm');
Route::post('login', 'App\Http\Controllers\Auth\AuthController@login');
Route::get('logout', 'App\Http\Controllers\Auth\AuthController@logout');
// Registration Routes...
Route::get('register', 'App\Http\Controllers\Auth\AuthController@showRegistrationForm');
Route::post('register', 'App\Http\Controllers\Auth\AuthController@register');
// Password Reset Routes...
Route::get('password/reset/{token?}', 'App\Http\Controllers\Auth\PasswordController@showResetForm');
Route::post('password/email', 'App\Http\Controllers\Auth\PasswordController@sendResetLinkEmail');
Route::post('password/reset', 'App\Http\Controllers\Auth\PasswordController@reset');

