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

Laravel 6自定义邮箱验证报错:getFromJson方法不存在

Fixing "Method Illuminate\Translation\Translator::getFromJson does not exist" in Laravel 6 Custom Email Verification

Hey there! I’ve run into this exact issue before with Laravel 6, so let’s break down what’s going on and how to fix it quickly.

The Root Cause

Laravel 6 fully removed the getFromJson method from the Translator class—it was deprecated in earlier versions and replaced with simpler, more consistent helper functions. Your custom email verification setup is still calling this old method somewhere, which is throwing the error. Clearing just the view cache isn’t enough because the problem lives in your code or templates, not cached views.

Step-by-Step Fixes

  • Check your email verification views
    Head to resources/views/auth/verify.blade.php (or any custom verification views you’ve created). Look for code snippets like:

    {{ trans()->getFromJson('auth.verify.title') }}
    

    Replace every instance of getFromJson with either the __() helper or trans():

    {{ __('auth.verify.title') }}
    {{-- OR --}}
    {{ trans('auth.verify.title') }}
    
  • Update your custom Verification Notification
    If you built a custom VerifyEmail notification (usually stored in app/Notifications), open that file and check the toMail method. You’ll likely see code like this:

    return (new MailMessage)
        ->line($this->translator->getFromJson('Please click the button below to verify your email address.'))
        ->action($this->translator->getFromJson('Verify Email Address'), $url);
    

    Swap out getFromJson with trans() or use the __() helper directly:

    return (new MailMessage)
        ->line(__('Please click the button below to verify your email address.'))
        ->action(__('Verify Email Address'), $url);
    
  • Clear all caches (not just views)
    Run these commands to ensure old cached code doesn’t interfere with your changes:

    php artisan config:clear
    php artisan route:clear
    php artisan cache:clear
    
  • Verify your language files
    Double-check that your language files (e.g., resources/lang/en/auth.php) have the correct keys for your verification messages. This ensures the __() or trans() functions can pull the right translations without issues.

Final Check

After making these updates, trigger the email verification flow again. The error should disappear once all old getFromJson calls are replaced with the current Laravel translation methods.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:17:05