Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

WARNING: You are browsing the documentation for Symfony 3.2 which is not maintained anymore. Consider upgrading your projects to Symfony 5.1.

How to Forward Requests to another Controller

3.2 version

How to Forward Requests to another Controller

Though not very common, you can also forward to another controller internally with the forward() method. Instead of redirecting the user’s browser, this makes an “internal” sub-request and calls the defined controller. The forward() method returns the Symfony\Component\HttpFoundation\Response object that is returned from that controller:

public function indexAction($name)
    $response = $this->forward('AppBundle:Something:fancy', array(
        'name'  => $name,
        'color' => 'green',

    // ... further modify the response or return it directly

    return $response;

The array passed to the method becomes the arguments for the resulting controller. The target controller method might look something like this:

public function fancyAction($name, $color)
    // ... create and return a Response object

Just like when creating a controller for a route, the order of the arguments of fancyAction() doesn’t matter: the matching is done by name.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.