mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
722 B
722 B
date | id | title |
---|---|---|
20201112 | 63017411-62dd-4586-86c5-4b0edc70114d | Always Include Route Default Values |
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)
{
// ...
}