Search code examples
phpsymfonyroutessymfony-3.2

how matching URI using Route annotation on symfony


example case URI: '/department/id/1'

Controller:

/**

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

it return me '1'

if I have URI:/department/id/1/category/id/2

how to form the @Route that capture 1 and 2 ?

please help thanks


Solution

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