-1

I mean creating an error 400, 500 generated by the ViewHandler of Fosrestbundle directly from the controller without using an Entity and a Form.

speeeeeed2006
  • 21
  • 1
  • 5

2 Answers2

0

You could add this line where ever you want the error

header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);

You may need to make sure no content has been sent prior to this error

Dale
  • 10,384
  • 21
  • 34
0

I don't know if i understood you question correctly but there are some possibilities.

return $this->view(null, 400);

You can return the view with the status code. In some cases i thow an HTTPException.

use Symfony\Component\HttpKernel\Exception\HttpException;

throw new HttpException(400, "Input not correct or not allowed!");

There you can define the status code and the error message.

René Höhle
  • 26,716
  • 22
  • 73
  • 82