当我的应用程序中抛出一些特定的异常时,我想做一些特殊的事情(记录,重定向,......)
我已经注册了一个eventlistener:
# config/services.yaml
services:
App\EventListener\ExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception }
在开发环境中,一切正常。
在prod-environment(debug = false)中,永远不会调用onKernelException(在App \ EventListener \ ExceptionListener中)。
调试事件调度程序确认我的侦听器未加载。
php bin/console debug:event-dispatcher kernel.exception --env=dev
------- ----------------------------------------------------------------------------------- ----------
Order Callable Priority
------- ----------------------------------------------------------------------------------- ----------
#1 App\EventListener\ExceptionListener::onKernelException() 0
#2 Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException() 0
#3 Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException() 0
#4 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -128
#5 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -256
php bin/console debug:event-dispatcher kernel.exception --env=prod
------- ----------------------------------------------------------------------------------- ----------
Order Callable Priority
------- ----------------------------------------------------------------------------------- ----------
#1 Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException() 0
#2 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -128
有人可以解释我做错了什么或为什么Symfony会这样做?