【发布时间】: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