[英]Class does not exist - Laravel
我正在學習本教程 。 我目前正在使用laravel 5.3,所以它有點過時了。 我按照教程的說法一步一步地完成了,但是,我得到了
ReflectionException in Container.php line 749:
Class First does not exist
in Container.php line 749
at ReflectionClass->__construct('First') in Container.php line 749
at Container->build('First', array()) in Container.php line 644
at Container->make('First', array()) in Application.php line 709
at Application->make('First') in Kernel.php line 173
at Kernel->terminate(object(Request), object(Response)) in index.php line 58
at require_once('C:\xampp5\htdocs\laravel\laravel\public\index.php') in server.php line 21
一切都像在教程中一樣。 我不知道問題出在哪里。
問題是你創建了一個FirstMiddleware
但你在這里只FirstMiddleware
First
:
<?php
Route::get('/usercontroller/path',[
'middleware' => 'First',
'uses' => 'UserController@showPath'
]);
正如官方文檔中所述,
如果您想將中間件分配給特定路由,則應首先在中間件中為您的
app/Http/Kernel.php
分配密鑰
因此,將其添加到您的app/Http/Kernel.php
文件中:
protected $routeMiddleware = [
// the other route middlewares are defined here
'First' => \App\Http\Middleware\FirstMiddleware::class, // add this line
]
我認為這應該足夠了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.