skip to Main Content

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' => IlluminateAuthMiddlewareEnsureEmailIsVerified::class,
];

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

2

Answers


  1. $middlewareAliases is NOT a class alias. You can do that with aliases in the app.php file

    $middlewareAliases is used for routes

    // allows for this
    Route::get('/', SomeController::class)->middleware('verified');
    
    // instead of this
    use IlluminateAuthMiddlewareEnsureEmailIsVerified::class;
    
    Route::get('/', SomeController::class)->middleware(EnsureEmailIsVerified::class);
    
    Login or Signup to reply.
    1. Clear you caches
    php artisan cache:clear
    php artisan route:clear
    php artisan config:clear
    php artisan view:clear
    
    1. Ensure that your Verified middleware is correctly assigned in your routes.
    Route::middleware('verified') - > group(function() {
      // Your routes
    });
    
    1. sometimes the composer autoload files might be out of date. run below command.
    composer dump-autoload
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search