如何在symfony上使用Route注释匹配URI

时间:2017-08-11 12:13:13

标签: php symfony routing symfony-3.2

示例案例URI:' / department / id / 1'

控制器:

/**

     @Route/department/id/{slug}
*/
        function($slug)
        return new Response($slug)

它返回我' 1'

如果我有URI: / department / id / 1 / category / id / 2

如何形成捕获1和2的@Route?

请帮助谢谢

1 个答案:

答案 0 :(得分:1)

/**
 @Route(/department/{slug}/category/{id}, name='department_category_detail')
*/
public function departmentCagetegoryDetailAction($slug, $id) {
    ....
}