【发布时间】:2021-01-21 12:35:45
【问题描述】:
登录到我的管理仪表板后,我收到以下错误:
ReflectionException 类 App\Http\Controllers\DashboardController 不存在
下面是我的DashboardController里面:public_html/app/Http/Controllers/Dashboard
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DashboardController extends Controller
{
public function index()
{
return view('dashboard.index');
}
}
路由文件:
Auth::routes();
Route::get('logout', function () {
\Illuminate\Support\Facades\Auth::logout();
return redirect('/');
});
Route::get('/', 'HomeController@index')->name('home');
//Route::get('/about', 'AboutController@index')->name('about');
Route::get('/events', 'EventController@index')->name('events');
Route::get('/events/{event}', 'EventController@show')->name('events.show');
Route::get('/publications', 'PublicationController@index')->name('publications');
Route::get('/publications/{publication}', 'PublicationController@show')->name('publications.show');
Route::middleware(['web', 'auth'])->group(function () {
Route::get('search/', 'SearchController@index')->name('search');
});
Route::middleware(['auth', 'dashboard'])->group(function () {
Route::get('/dashboard', 'DashboardController@index')->name('dashboard.index');
Route::resource('/dashboard/users/trashed', 'UserTrashedController', ['as' => 'dashboard.users']);
Route::resource('/dashboard/users', 'UserController', ['as' => 'dashboard']);
Route::resource('/dashboard/categories/trashed', 'CategoryTrashedController', ['as' => 'dashboard.categories']);
Route::resource('/dashboard/categories', 'CategoryController', ['as' => 'dashboard']);
Route::resource('/dashboard/events', 'Dashboard\EventController', ['as' => 'dashboard']);
Route::resource('/dashboard/activity-logs', 'ActivityLogController', ['as' => 'dashboard']);
Route::resource('/dashboard/pages', 'Dashboard\PageController', ['as' => 'dashboard']);
Route::resource('/dashboard/publications', 'Dashboard\PublicationController', ['as' => 'dashboard']);
});
Route::any('/{any}', '\App\Http\Controllers\PageController@show')->where('any', '.*')->name('pages.show');
下面是我的 laravel 版本
Laravel 版本:5.8
我已经花了几个小时,但无法找到问题,有人可以帮我解决问题
【问题讨论】:
-
Welcome to SO .... 您能否调整
DashboardController中定义的命名空间以镜像文件夹结构,并添加Dashboard部分? -
感谢@lagbox 的回复,我也试过了 namespace App\Http\Controllers\Dashboard;没用,你能告诉我这是不是你的意思吗