user26776
user26776

Reputation: 131

Send 2 parameters - FOSRestController

I am wearing the FOSRestController to create an api the only problem and wanted to send 2 parameters in the get method and i am not able to .

This and my function

public function getSearchAction($search, $pag)
    {
      }

In the router debug appears only to send 1 parameter.

Hello

Someone knows I send the 2 parameters ?

Thanks.

Upvotes: 0

Views: 111

Answers (1)

martin
martin

Reputation: 96891

I actually does work for me. Although this didn't generate the same route as yours.

public function getSearchAction($search, $page)
{
}

Generates route:

get_search     GET    ANY    ANY      /whatever/{search}/search/{page}.{_format}

Did you clear cache before running app/console debug:router?

If it still doesn't work for you, there's an annotation FOS\RestBundle\Controller\Annotations\Get to manualy setup a route:

/**
 * @Get("/search/{term}/{page}")
 */
public function getSearchAction(Request $request, $term, $page)
{

}

Which generates route:

get_search     GET    ANY    ANY      /whatever/search/{term}/{page}.{_format}

Upvotes: 2

Related Questions