Target class controller does not exist - Laravel 8

前端 未结 14 2412
你的背包
你的背包 2020-11-22 05:43

Here is my controller:



        
14条回答
  •  轮回少年
    2020-11-22 06:07

    • Yes in laravel 8 this error is occur..
    • After try many solutions I got these perfect solution
    • Just follow the steps...

    CASE - 1

    We can change in api.php and in web.php files like bellow..
    The current way we write syntex is

    Route::get('login', 'LoginController@login');
    

    should changed to

    Route::get('login', [LoginController::class, 'login']);
    

    CASE - 2

    1. First go to the file: app > Providers > RouteServiceProvider.php
    2. In that file replace the line
      protected $namespace = null; with protected $namespace = 'App\Http\Controllers';
    3. Then After add line ->namespace($this->namespace) as shown in image..

提交回复
热议问题