diff --git a/controller.rst b/controller.rst index 0f2d5b76bac..6837c28c837 100644 --- a/controller.rst +++ b/controller.rst @@ -502,6 +502,14 @@ payload formats:: // ... } +.. tip:: + + If you build a JSON API, make sure to declare your route as using the JSON + :ref:`format `. This will make the error handling + output a JSON response in case of validation errors, rather than an HTML page:: + + #[Route('/dashboard', name: 'dashboard', format: 'json')] + Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_ if you want to map a nested array of specific DTOs::