event - symfony request How to monitor requests?
滿天的星座
滿天的星座 2017-05-16 16:43:50
0
1
500

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 }
  
滿天的星座
滿天的星座

reply all(1)
给我你的怀抱

Is there something wrong with your code

use Symfony\Component\HttpKernel\Event\GetResponseEvent;

class RequestListener
{
    public function onKernelRequest(GetResponseEvent $event)
    {
        dump('test');
        //TODO: 对某些url做特殊分析 
    }

}

You will know the reason after modifying it like this

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template