【问题标题】:laravel 5.7 Class 'Illuminate\Support\Facades\Lang' not foundlaravel 5.7 类 'Illuminate\Support\Facades\Lang' 未找到
【发布时间】:2019-06-05 14:28:26
【问题描述】:

我最近遇到了这个错误:

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 文件进行翻译。

任何想法是什么导致了错误?

【问题讨论】:

  • vendor/laravel/framework/src/Illuminate/Support/Facades/Lang.php 有文件吗?
  • 是的文件存在
  • 我会先尝试吹走vendor,然后重新尝试composer install。这应该可以防止权限问题并为您提供一组干净的文件。
  • composer install 重新生成vendor 目录。
  • 如果您删除了供应商目录,就会出现这种情况。 vendor 不应包含手动修改的代码,因此删除它并使用 composer install 重新生成它应该可以解决 ceejayoz 上面多次建议的任何依赖问题。

标签: json laravel notifications lang reset-password


【解决方案1】:

喜欢@ceejayoz 建议,删除供应商文件夹并运行composer install 解决了问题

谢谢大家的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-15
    • 2021-01-08
    • 2020-01-27
    • 2019-11-29
    • 2019-12-30
    • 2017-03-08
    • 2020-01-24
    相关资源
    最近更新 更多