Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 4+;Swift Mailer-从127.0.0.1发送电子邮件时出错_Php_Symfony_Swiftmailer - Fatal编程技术网

Php Symfony 4+;Swift Mailer-从127.0.0.1发送电子邮件时出错

Php Symfony 4+;Swift Mailer-从127.0.0.1发送电子邮件时出错,php,symfony,swiftmailer,Php,Symfony,Swiftmailer,Symfony 4应用程序使用Swift Mailer发送电子邮件 我已经编写了我的控制器逻辑,并创建了一个表单和电子邮件,所有这些都在生产服务器上工作 但是,在开发模式下,从php bin/console服务器运行:runI得到错误: Service "logger" not found: even though it exists in the app's container, the container inside "App\Controller\PageController" is a

Symfony 4应用程序使用Swift Mailer发送电子邮件

我已经编写了我的控制器逻辑,并创建了一个表单和电子邮件,所有这些都在生产服务器上工作

但是,在开发模式下,从
php bin/console服务器运行:run
I得到错误:

Service "logger" not found: even though it exists in the app's container, the container inside "App\Controller\PageController" is a smaller service locator that only knows about the "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services.

Try using dependency injection instead.

我只是按原样使用这个包。为什么我不能从本地开发环境发送电子邮件?

您以某种方式在
App\Controller\PageController
中替换了Symfony的默认容器。此消息基本上意味着,没有在容器中设置对象及其依赖项。详情请参阅:


Symfony使用容器模式,它在一个容器中保存许多对象,可以通过整个应用程序访问这些对象。

所以您没有使用依赖项注入?为什么?看到这个答案,它可能是解决方案:“不知何故”是因为他们正在使用现在的标准AbstractController。这基本上是一个仅链接的答案,实际上并没有回答这个问题。可以考虑用实际的解决方案进行更新。因此,我应该在控制器类中扩展控制器而不是抽象控件。为什么斯威夫特·梅勒不喜欢抽象控制器?