Search code examples
phplaravellaravel-10laravel-jetstream

jetstream Class "verified" does not exist


I'm new to Laravel 10, and I recently installed Jetstream. When I run php artisan route:list in the console, I get the following error: Class "verified" does not exist.

I do have verified in my Kernel:

protected $middlewareAliases = [
    ...
    ...
    'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

in my route in web.php i have this

Route::group(['middleware' => ['verified', 'web']],function(){
  Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
});

in jetstream.php there is this 'middleware' => ['auth', 'verified', 'web'],

and this is the error i see on console

   ReflectionException 

  Class "verified" does not exist

  at vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:225
    221▕             if ($this->isFrameworkController($route)) {
    222▕                 return false;
    223▕             }
    224▕ 
  ➜ 225▕             $path = (new ReflectionClass($route->getControllerClass()))
    226▕                                 ->getFileName();
    227▕         } else {
    228▕             return false;
    229▕         }

      +3 vendor frames 

  4   [internal]:0
      Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
      +16 vendor frames 

  21  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

I don't know what I'm missing or how to fix this.


Solution

  • Route::group(['middleware' => 'verified', 'web'],function(){ Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard'); });..... I don't think that's a correct way to define multiple middleware you should pass them as an array like this:['middleware' => ['verified', 'web']] Try this. further if you make any changes in your routes and any issue comes up that you may not expect, it is possible that it can get solved using this commands: php artisan optimize php artisan cache:clear