Target class controller does not exist - Laravel 8

前端 未结 14 2148
你的背包
你的背包 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'));
            });
    }
    
    0 讨论(0)
  • 2020-11-22 06:19

    In laravel-8 you can use like this

     Route::group(['namespace'=>'App\Http\Controllers', 'prefix'=>'admin',
     'as'=>'admin.','middleware'=>['auth:sanctum', 'verified']], function()
    {
        Route::resource('/dashboard', 'DashboardController')->only([
            'index'
        ]);
    });
    

    Thanks

    0 讨论(0)
提交回复
热议问题