I am following this tutorial. I am currently using laravel 5.3 so it is a little outdated. I have done step by step as said by the tutorial, however, I get
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
Everything is just like in the tutorial. I have no idea where could be the problem.
A ReflectionException occurs when there's an error while performing any sort of reflection; specifically when dealing with the Reflector , or with other classes that inherit from it.
The problem is that you created a FirstMiddleware
but you referred to it only as First
here:
<?php
Route::get('/usercontroller/path',[
'middleware' => 'First',
'uses' => 'UserController@showPath'
]);
As stated in the official docs,
if you would like to assign middleware to specific routes, you should first assign the middleware a key in your
app/Http/Kernel.php
So, add this to your app/Http/Kernel.php
file:
protected $routeMiddleware = [
// the other route middlewares are defined here
'First' => \App\Http\Middleware\FirstMiddleware::class, // add this line
]
I think this should be enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With