Target class controller does not exist - Laravel 8

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

Here is my controller:



        
14条回答
  •  余生分开走
    2020-11-22 06:17

    in laravel-8 default remove namespace prefix so you can set old way in laravel-7 like:

    in RouteServiceProvider.php add this variable

    protected $namespace = 'App\Http\Controllers';
    

    and update boot method

    public function boot()
    {
           $this->configureRateLimiting();
    
           $this->routes(function () {
                Route::middleware('web')
                    ->namespace($this->namespace)
                    ->group(base_path('routes/web.php'));
    
                Route::prefix('api')
                    ->middleware('api')
                    ->namespace($this->namespace)
                    ->group(base_path('routes/api.php'));
            });
    }
    

提交回复
热议问题