laravel 5.7类'Illuminate \ Support \ Facades \ Lang'未找到

时间:2019-01-10 16:52:55

标签: json laravel notifications lang reset-password

我最近遇到此错误:

Class 'Illuminate\Support\Facades\Lang'not found 
{"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Support\\Facades\\Lang' 
    not found at vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php:60)

我不得不更改代码形式:

return (new MailMessage)
    ->subject(Lang::getFromJson('Reset Password Notification'))
    ->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
    ->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', $this->token, false)))
    ->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));

收件人:

return (new MailMessage)
    ->subject(__('Reset Password Notification'))
    ->line(__('You are receiving this email because we received a password reset request for your account.'))
    ->action(__('Reset Password'), url(config('app.url').route('password.reset', $this->token, false)))
    ->line(__('If you did not request a password reset, no further action is required.'));

它有效,但是每次更新后我都必须这样做。

文件 vendor \ laravel \ framework \ Illuminate \ Support \ Facades \ Lang.php

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static mixed trans(string $key, array $replace = [], string $locale = null)
 * @method static string transChoice(string $key, int|array|\Countable $number, array $replace = [], string $locale = null)
 * @method static string getLocale()
 * @method static void setLocale(string $locale)
 * @method static string|array|null get(string $key, array $replace = [], string $locale = null, bool $fallback = true)
 *
 * @see \Illuminate\Translation\Translator
 */
class Lang extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'translator';
    }
}
  

注意:我正在使用JSON文件进行翻译。

有什么想法会导致错误?

1 个答案:

答案 0 :(得分:0)

就像@ceejayoz一样,建议删除供应商文件夹并运行composer install解决了问题

谢谢大家的帮助!