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

Laravel Fortify中verification.verify路由未定义问题求助

Laravel Fortify邮箱验证路由缺失问题排查与解决

针对你遇到的Route [verification.verify] not defined错误,可按以下步骤排查:

  • 确认Fortify路由已注册
    检查routes/web.php文件,确保已添加Fortify路由注册代码:

    use Laravel\Fortify\Fortify;
    
    Fortify::routes();
    

    Fortify的邮箱验证路由是通过这个方法自动注册的,若缺少该行代码,相关路由不会生成。

  • 验证features配置正确性
    打开config/fortify.php,确保features数组中正确启用邮箱验证特性,需完整引用Features类:

    use Laravel\Fortify\Features;
    
    'features' => [
        Features::emailVerification(),
        // 其他已启用的特性
    ],
    

    若仅用字符串或未正确导入Features类,邮箱验证路由不会被加载。

  • 检查Fortify服务提供者注册
    确认config/app.php的providers数组中已包含Fortify服务提供者:

    'providers' => [
        // ... 其他服务提供者
        Laravel\Fortify\FortifyServiceProvider::class,
    ],
    

    未注册该提供者会导致Fortify所有功能(包括路由)无法正常加载。

  • 彻底清除缓存
    执行以下命令清除所有缓存,确保配置变更生效:

    php artisan route:clear
    php artisan optimize:clear
    

    若之前缓存过路由,单纯修改配置不会自动更新路由列表。

  • 确认User模型接口实现无误
    确保User模型正确实现MustVerifyEmail接口,代码示例:

    use Illuminate\Contracts\Auth\MustVerifyEmail;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    
    class User extends Authenticatable implements MustVerifyEmail
    {
        // 模型其他代码
    }
    

    该接口是启用邮箱验证的前提条件,若未正确实现,Fortify不会加载对应路由。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 14:27:42