mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 04:56:23 +00:00
675 B
675 B
id | title |
---|---|
e85e1d41-4327-4a38-b4f9-205e7ccec209 | Inlined Routing Configuration |
Introduction
Added in Symfony 4.1, inlined routing configuration allows us to define requirements and default values for route placeholders.
Syntax
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends Controller
{
/**
* @Route("/blog/{page}", name="blog_list", requirements={"page"="\d+"}, defaults={"page"="1"})
*/
public function list($page)
{
// ...
}
}
is now
/**
* @Route("/blog/{page<\d+>?1}", name="blog_list")
*/
public function list($page)
{
// ...
}