You should use the $server
parameter of the $client-request()
method to set the Accept
header to application/json
. FOSRestBundle
has a listener that returns JSON
only if the corresponding Accept
header is received, otherwise it will search for the template corresponding to the controller.
$client->request('GET', '/account', array(), array(), array('HTTP_ACCEPT' => 'application/json'));