我正在使用 Laravel 8 来开发我的项目。我制作了一个名为 BackendController
的 Controller 并添加此 index()
调用 Blade 的方法:
public function index()
{
return view('website.backend.dashboard.index');
}
然后web.php
我添加这条路线:
Route::get('/dashboard', 'BackendController@index');
但是当我转到/dashboard
时,它说:
lluminate\Contracts\Container\BindingResolutionException 目标类[BackendController]不存在。
我不知道为什么它会打印这个,因为 Controller 已经存在了!所以如果你知道如何解决这个问题,请帮助我......
提前致谢。
最佳答案
Laravel 8 更新了其路由。
它已记录,请查找 Routing Namespace Updates 部分
在新的 Laravel 8.x 应用程序中, Controller 路由定义应使用标准 PHP 可调用语法来定义;
use App\Http\Controllers\UserController;
Route::get('/users', [UserController::class, 'index']);
关于php - 拉拉维尔 8 : Target class does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64313435/