从更新symfony后2.3
,2.4
我得到了ServiceNotFoundException
Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "monolog.handler.mojhandler" has a dependency on a non-existent service "swiftmailer.transport.real".' in E:\wamp\www\project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php on line 59
这是我的config_prod.yml
imports: - { resource: config.yml } monolog: handlers: main: type: fingers_crossed action_level: error handler: streamed streamed: type: stream path: %kernel.logs_dir%/%kernel.environment%.log level: debug mail: type: fingers_crossed action_level: error handler: buffered channels: ["!app"] # Dont log app because we dont' want 404 errors sending buffered: type: buffer handler: mojhandler mojhandler: type: swift_mailer from_email: %mojhandler_logger_email% to_email: %mojhandler_logger_email% subject: "[Panel] An Error Occurred!" level: debug
这是来自config.yml的我的swiftmailer配置
# Swiftmailer Configuration swiftmailer: transport: %mailer_transport% host: %mailer_host% username: %mailer_user% password: %mailer_password% port: %mailer_port% auth_mode: %mailer_auth_mode% encryption: %mailer_encryption%
我该如何解决?
如果不在swiftmailer配置中设置'spool'配置值,那似乎确实是一个错误。
为了解决这个问题,我不得不自己在其中一个services.yml中创建缺少的服务(因为我不想使用假脱机):
swiftmailer.transport.simplemailinvoker: class: Swift_Transport_SimpleMailInvoker swiftmailer.transport.eventdispatcher: class: Swift_Events_SimpleEventDispatcher swiftmailer.transport.real: class: Swift_Transport_MailTransport arguments: [@swiftmailer.transport.simplemailinvoker, @swiftmailer.transport.eventdispatcher]