jetstream Class "verified" does not exist

35 views Asked by At

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.

1

There are 1 answers

0
Jaimin Parikh On BEST ANSWER

I don't think that's the correct way to define multiple middleware. You should pass them as an array like this: ['middleware' => ['verified', 'web']].

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

Furthermore, if you make any changes in your routes and an unexpected issue arises, it's possible that it can be resolved using these commands:

php artisan optimize 
php artisan cache:clear