Laravel 5.3 中不存在类 App\Http\Controllers\Auth\LoginController
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41747963/
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
Class App\Http\Controllers\Auth\LoginController does not exist in laravel 5.3
提问by Jaymin Panchal
I created a multi auth in Laravel 5.3,
我在 Laravel 5.3 中创建了一个多重身份验证,
Then moved Controller/Auth/[files]
to:
然后转移Controller/Auth/[files]
到:
Admin: Controller/Admin/Auth/[files]
&
管理员:Controller/Admin/Auth/[files]
&
Site: Controller/Site/Auth/[files]
地点: Controller/Site/Auth/[files]
In command line I type php artisan route:list
,
在命令行我输入php artisan route:list
,
It shows me following error:
它向我显示以下错误:
Class App\Http\Controllers\Auth\LoginController does not exist
类 App\Http\Controllers\Auth\LoginController 不存在
Where is my problem?
我的问题在哪里?
回答by Jaymin Panchal
You need to manually define all the Auth
routes in web.php
and remove Auth::routes()
.
您需要手动定义所有Auth
路由web.php
并删除Auth::routes()
.
just define all your routes like,
只需定义所有路线,例如,
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {
Route::get('/', 'Auth\LoginController@showLoginForm');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout');
});
回答by Alexey Mezenin
If you're moving controllers to a custom directory, you shouldn't use auth routes. So remove this from routes file:
如果您要将控制器移动到自定义目录,则不应使用 auth 路由。所以从路由文件中删除它:
If you're using 5.2
如果您使用的是 5.2
Route::auth();
If you're using 5.3
如果您使用的是 5.3
Auth::routes();
And then build auth routes manually.
然后手动构建认证路由。
回答by Rogier Wijsman
The two default authentication controllers provided with the framework have been split into four smaller controllers. The easiest way to upgrade your application to the new authentication controllers is to grab a fresh copy of each controller from GitHub and place them into your application.
框架提供的两个默认身份验证控制器已拆分为四个较小的控制器。将您的应用程序升级到新的身份验证控制器的最简单方法是从 GitHub 获取每个控制器的新副本并将它们放入您的应用程序中。
https://github.com/laravel/laravel/tree/5.3/app/Http/Controllers/Auth
https://github.com/laravel/laravel/tree/5.3/app/Http/Controllers/Auth
You should also make sure that you are calling the Auth::routes() method in your routes/web.php file. This method will register the proper routes for the new authentication controllers.
您还应该确保您正在调用 routes/web.php 文件中的 Auth::routes() 方法。此方法将为新的身份验证控制器注册正确的路由。
Pasted this answer from the Laravel upgrade documentation.
从 Laravel 升级文档中粘贴了这个答案。
回答by Niket Joshi
Hello please check your route/web.php
您好,请检查您的路线/web.php
/* For get login page*/
Route::get('/login', function () {return view('auth.login');});
/* while post remember to user Auth\controllername so you can get the perfect path for the custom login */
Route::post('/login', 'Auth\LoginController@authentication')->name('login');
回答by Mohammed Bayomy
It Happens With Me Now And I Had Solved It By Another Way
它现在发生在我身上,我用另一种方式解决了它
Simply Copy The Auth Folder And Put It In The Path Of Admin Controllers Folder
只需复制Auth文件夹并将其放在Admin Controllers文件夹的路径中
And Open Each File And Change
并打开每个文件并更改
namespace App\Http\Controllers\Auth;
命名空间 App\Http\Controllers\Auth;
To
到
namespace App\Http\Controllers\Dashboard\Auth;
命名空间 App\Http\Controllers\Dashboard\Auth;
Hope It Just Helps Somebody
希望它可以帮助某人
回答by Lalit Baghel
add this
添加这个
namespace App\Http\Controllers;
回答by Faridul Khan
Download or copy RegisterController.php from another project. Paste it in your project under
从另一个项目下载或复制 RegisterController.php。将其粘贴到您的项目下
Controllers/Auth/[files]
控制器/身份验证/[文件]
That's it
就是这样