code: public function onKernelRequest(GetResponseEvent $event)
      {
          $request = $event->getRequest();
          if ($request->get('_controller')) {
              return;
          }
  
          $routeInfo = $this->dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
          switch ($routeInfo[0]) {
              case Dispatcher::NOT_FOUND:
                  $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo());
  
                  throw new NotFoundHttpException($message);
  
              case Dispatcher::METHOD_NOT_ALLOWED:
                  $allowedMethods = $routeInfo[1];
                  $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getPathInfo(), implode(', ', $allowedMethods));
  
                  throw new MethodNotAllowedHttpException($allowedMethods, $message);
  
              case Dispatcher::FOUND:
                  $handler = $routeInfo[1];
                  $vars = $routeInfo[2];
  
                  $request->attributes->add($vars);
                  $request->attributes->set('_controller', $handler);
  
                  break;
          }
      }
docs: @param GetResponseEvent $event
  
  @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException