Description

Sometimes when generating URLs you have situations where you don’t want the default value in the URL.

Syntax

/**
 * @Route("/blog/{!page}", name="blog_list")
 */
public function list($page = 1)
{
    // ...
}
$url = $router->generate('blog_list');                // $url = '/blog/1'
$url = $router->generate('blog_list', ['page' => 1]); // $url = '/blog/1'
$url = $router->generate('blog_list', ['page' => 7]); // $url = '/blog/7'
/**
 * @Route("/blog/{page}.{!_format<html|json>?html}", name="blog_list")
 */
public function list($page = 1)
{
    // ...
}