简体   繁体   中英

Target [Illuminate\View\ViewFinderInterface] is not instantiable while building [Illuminate\View\Factory]

After upgrade my app from lumen8 to lumen9 I got this error when I try to send an email with component in template.

[2022-12-21 12:06:40] local.ERROR: Target [Illuminate\View\ViewFinderInterface] is not instantiable while building [Illuminate\View\Factory]. (View: D:\projects\blog\resources\views\emails\test.blade.php)  

This template don't work, raise the error

<x-mail::message>
# Order Shipped
Your order has been shipped!
Thanks,<br>
{{ config('app.name') }}
</x-mail::message>

This template work (not as expected but work)

# Order Shipped
Your order has been shipped!
Thanks,<br>
{{ config('app.name') }}

there seems to be something incomplete in the documentation when migrate from lumen8.

I've tried also to create a new project with the same error.

Someone has lumen9 mail working example?

I encountered the same issue after upgrading to Lumen 9. After thoroughly examining the Laravel codebase, I found a solution. To fix this issue, add the following lines of code to bootstrap/app.php :

$app->configure('view');
$app->alias('view', Illuminate\View\Factory::class);

Additionally, the final configuration should look like this:

$app->configure('view');
$app->configure('mail');
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class);
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
$app->alias('view', Illuminate\View\Factory::class);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM