@@ -601,10 +601,10 @@ Returning JSON Response
601
601
To return JSON from a controller, use the ``json() `` helper method. This returns a
602
602
``JsonResponse `` object that encodes the data automatically::
603
603
604
- use Symfony\Component\HttpFoundation\Response ;
604
+ use Symfony\Component\HttpFoundation\JsonResponse ;
605
605
// ...
606
606
607
- public function index(): Response
607
+ public function index(): JsonResponse
608
608
{
609
609
// returns '{"username":"jane.doe"}' and sets the proper Content-Type header
610
610
return $this->json(['username' => 'jane.doe']);
@@ -623,10 +623,10 @@ Streaming File Responses
623
623
You can use the :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ AbstractController::file `
624
624
helper to serve a file from inside a controller::
625
625
626
- use Symfony\Component\HttpFoundation\Response ;
626
+ use Symfony\Component\HttpFoundation\BinaryFileResponse ;
627
627
// ...
628
628
629
- public function download(): Response
629
+ public function download(): BinaryFileResponse
630
630
{
631
631
// send the file contents and force the browser to download it
632
632
return $this->file('/path/to/some_file.pdf');
@@ -638,7 +638,7 @@ The ``file()`` helper provides some arguments to configure its behavior::
638
638
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
639
639
// ...
640
640
641
- public function download(): Response
641
+ public function download(): BinaryFileResponse
642
642
{
643
643
// load the file from the filesystem
644
644
$file = new File('/path/to/some_file.pdf');
0 commit comments