gpt4 book ai didi

symfony - 为什么 Symfony 不自动连接邮件程序、路由器?

转载 作者:行者123 更新时间:2023-12-01 08:47:53 25 4
gpt4 key购买 nike

我使用 Symfony 4。我想在我的服务中使用路由器和邮件程序。我使用依赖注入(inject)将它们包括在内。

public function __construct(Swift_Mailer $mailer, EngineInterface $templating, RouterInterface $router)
{
$this->mailer = $mailer;
$this->router = $router;
$this->templating = $templating;
}

我收到此错误:
argument "$templating" of method "__construct()" references interface "Symfony\Component\Templating\EngineInterface" but no such service exists. It cannot be auto-registered because it is from a different root namespace. Did you create a class that implements this interface?

在 Symfony 4 中使用 Mailer、Router 服务的任何提示?

最佳答案

我不得不 composer require symfony/templating为了得到Symfony\Bundle\FrameworkBundle\Templating\EngineInterface服务。

还必须在 framework 下添加以下配置:

templating:
enabled: false
engines: ['twig']

关于symfony - 为什么 Symfony 不自动连接邮件程序、路由器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49399819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com