gpt4 book ai didi

Laravel 8 - 路由找不到 Controller : Target class [Auth\LoginController] does not exist

转载 作者:行者123 更新时间:2023-12-03 18:32:07 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Target class controller does not exist - Laravel 8

(19 个回答)


去年关闭。




我今天去试了一下 Laravel 8,但似乎 Route 门面找不到 Controller 了。
路线/home给我这个错误:

Target class [HomeController] does not exist.


运行时出现类似错误: php artisan route:list
Illuminate\Contracts\Container\BindingResolutionException

Target class [Auth\LoginController] does not exist.

at C:\...\vendor\laravel\framework\src\Illuminate\Container\Container.php:811
811 throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);

最佳答案

感谢lagbox,我最终添加了namespace('App\Http\Controllers')到 RouteServiceProvider 启动方法中的 web 路由:

public function boot()
{
$this->configureRateLimiting();

$this->routes(function () {
Route::middleware('web')
->namespace('App\Http\Controllers')
->group(base_path('routes/web.php'));
这对我有用。任何更好的解决方案将是最受欢迎的。

关于Laravel 8 - 路由找不到 Controller : Target class [Auth\LoginController] does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63807759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com