从2.3
更新symfony到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%
我该如何解决?
答案 0 :(得分:4)
如果我们不在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]
答案 1 :(得分:2)
当升级到Monolog Bundle 2.5.0时,如果你没有在swiftmailer配置下设置'spool'配置值,那么这似乎是一个错误。