I need to monitor http request requests, do event monitoring and do some data statistics, but I found that after writing this, my requests will not be monitored. Has anyone done similar examples?
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class RequestListener
{
public function onKernelRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
//TODO: 对某些url做特殊分析
return;
}
}
}
kernel.event_listener.api_request_listener:
class: Morning\CommonBundle\EventListener\RequestListener
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest , priority: 0 }
Is there something wrong with your code
You will know the reason after modifying it like this