【问题标题】:InvalidArgumentException : View [themes.] not foundInvalidArgumentException:未找到查看 [主题。]
【发布时间】:2020-02-15 21:58:46
【问题描述】:

我突然收到以下错误消息。

InvalidArgumentException:未找到视图 [主题。]。 异常跟踪: 1 Illuminate\View\FileViewFinder::findInPaths("themes.") C:\xampp\htdocs\RoosterIKEA\vendor\laravel\framework\src\Illuminate\View\FileViewFinder.php:92 2 Illuminate\View\FileViewFinder::findNamespacedView("mail::themes.") C:\xampp\htdocs\RoosterIKEA\vendor\laravel\framework\src\Illuminate\View\FileViewFinder.php:76

知道这可能是哪个文件以及发生了什么吗?

【问题讨论】:

  • 发布您的邮件视图

标签: laravel


【解决方案1】:

在课堂Illuminate\Mail\Markdown第64行

return new HtmlString(($inliner ?: new CssToInlineStyles)->convert(
    $contents, $this->view->make('mail::themes.'.$this->theme)->render()
));

$this->theme 似乎是一个空字符串

现在该类已经在第 24 行定义了属性

/**
 * The current theme being used when generating emails.
 *
 * @var string
 */
protected $theme = 'default';

这意味着你可能已经用一个空字符串或者你的 markdown mailable 中的一个空值覆盖了这个属性

如果您通过

发布组件
php artisan vendor:publish --tag=laravel-mail

您将在 resources/views/vendor/mail/html/themes 中看到一个名为 default.css 的 CSS 文件

我找到了一种方法来重现此错误,以便有一个像这样的 Mailable 类

运行

php artisan make:mail OrderShipped --markdown=emails.orders.shipped

然后用空字符串覆盖主题属性

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;

    protected $theme = ''; // <--- HERE

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->markdown('emails.orders.shipped');
    }
}

现在发送电子邮件

use App\User;
use App\Mail\OrderShipped;

Route::get('/', function () {
    \Mail::to(User::first())->send(new OrderShipped());
});

你会得到同样的错误

这里的解决方案是删除 protected $theme = ''; 属性或将其设置为 default

希望对你有帮助

【讨论】:

  • 感谢您的回复。我确实已经正确地拥有了该文件。我做错的是'config/mail'中的mail.php文件有'markdown'=> ['theme'=>'','
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-26
  • 2019-01-23
  • 2017-03-28
  • 1970-01-01
相关资源
最近更新 更多