After a user submits a form, I want to render a view file, and right after that I want to initiate a background task to process five MS Excel files (each may have up to 2000 row
For using in controller:
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
$myVar = new MyObject();
$this->get('event_dispatcher')->addListener(KernelEvents::TERMINATE, function(PostResponseEvent $event) use($myVar) {
//You logic here
$request = $event->getRequest();
$test = $myVar->getMyStuff();
});
But it is not a good practice, please read about normal registering event listeners
kernel.terminate event will be dispatched after sending the response to user.