This package is abandoned and no longer maintained. No replacement package was suggested.

Simply auto-complete needed route parameters with existing ones.

v2.1.0 2017-09-21 08:23 UTC

This package is auto-updated.

Last update: 2022-09-23 13:36:13 UTC


Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to

Rapid Application Development : Url Generation

Simply auto-complete needed route parameters with existing ones.

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License

Official maintainers:


composer require knplabs/rad-url-generation ~2.0
class AppKernel
    function registerBundles()
        $bundles = array(
            new Knp\Rad\UrlGeneration\Bundle\UrlGenerationBundle(),


        return $bundles;


Just continue to use former url generation, nothing changes concerning the implementation. The only change is you don't repeat current route parameters anymore.

Example 1

Current route:

    path: /shops/{shop}/products/{products}/

My current url is /shops/12/products/345/. I want to build again the same url. Should I repeat route parameters if it already is my current route?


$router->generate('app_products_show');                                  // Returns /shops/12/products/345/
$router->generate('app_products_show', ['product' => 122]);              // Returns /shops/12/products/122/
$router->generate('app_products_show', ['shop' => 1]);                   // Returns /shops/1/products/345/
$router->generate('app_products_show', ['shop' => 1, 'product' => 122]); // Returns /shops/1/products/122/

Example 2

Current route:

    path: /shops/{shop}/products/{products}/

Current URL: /shops/1/products/122/

I want to build this URL

    path: /shops/{shop}/products/{products}/variants/{variant}/

I could execute:

$router->generate('app_variant_show', ['shop' => 1, 'product' => 122, 'variant' => 23]); // Returns /shops/1/products/122/variants/23/

But why should I repeat already existing parameters ?

$router->generate('app_variant_show', ['variant' => 23]); // Returns /shops/1/products/122/variants/23/

Works with

  • Router service : $container->get('router')->generate('app_products_show').
  • Controller shortcuts: $this->generateUrl('app_products_show') and $this->redirectToRoute('app_products_show').
  • Twig functions: path('app_products_show') or url('app_products_show').
  • Everything else using the Symfony router.