You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决Laravel 10执行php artisan route:list时的‘Class verified不存在’错误

解决Laravel 10 + Jetstream中「Class 'verified' does not exist」错误

问题排查及修复步骤

1. 修正路由组中间件写法

你在web.php里的路由组写法存在语法错误:

// 错误写法
Route::group(['middleware' => 'verified', 'web'], function () {
    // 路由内容
});

这里'web'被识别为数组的独立键名,而非middleware对应的中间件列表元素。正确写法需将所有中间件放入middleware对应的数组中:

// 正确写法
Route::group(['middleware' => ['web', 'verified']], function () {
    // 路由内容
});

2. 清除Laravel缓存

若之前执行过配置或路由缓存操作,修改后的配置不会自动生效,需手动清除缓存:

php artisan config:clear
php artisan route:clear
php artisan cache:clear

3. 核对Kernel.php的中间件别名配置

再次检查app/Http/Kernel.php的middlewareAliases数组,确保'verified'的映射无拼写错误:

protected $middlewareAliases = [
    // 其他中间件别名
    'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

注意类名和命名空间完全匹配,无大小写或字符遗漏。

4. 确认Jetstream配置的中间件格式

检查config/jetstream.php中的middleware配置,确保是正确的数组格式:

'middleware' => ['auth', 'verified', 'web'],

若修改过该配置,务必执行配置缓存清除命令让新配置生效。

完成以上操作后,重新执行php artisan route:list即可解决错误。

内容的提问来源于stack exchange,提问作者Shaho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 01:04:56