Add documentation for the new BinaryFileResponse class (#1866) #2416

Merged
merged 3 commits into from Apr 4, 2013

Projects

None yet

4 participants

@jbafford
Q A
Doc fix? yes
New docs? yes (symfony/symfony#4546)
Applies to 2.2
Fixed tickets #1866
@wouterj wouterj commented on an outdated diff Mar 30, 2013
book/controller.rst
@@ -726,8 +726,11 @@ headers and content that's sent back to the client::
.. tip::
- There is also a special :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`
- class that helps return JSON responses. See :ref:`component-http-foundation-json-response`.
+ There are also special classes to make certain kinds of responses easier:
+ - For JSON, there is :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`.
@wouterj
wouterj Mar 30, 2013 Symfony member

please add an empty line before this one

@wouterj wouterj commented on an outdated diff Mar 30, 2013
components/http_foundation/introduction.rst
@@ -406,13 +406,15 @@ represented by a PHP callable instead of a string::
});
$response->send();
-Downloading Files
+.. _component-http-foundation-serving-files:
+
+Serving Files
~~~~~~~~~~~~~~~~~
@wouterj
wouterj Mar 30, 2013 Symfony member

a couple ~ to much here

@wouterj wouterj commented on an outdated diff Mar 30, 2013
components/http_foundation/introduction.rst
@@ -424,6 +426,26 @@ abstracts the hard work behind a simple API::
$response->headers->set('Content-Disposition', $d);
+.. versionadded:: 2.2
+ The :class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse` class was added in Symfony 2.2.
@wouterj
wouterj Mar 30, 2013 Symfony member

You should break the line after the first word crossing the 72 character

@wouterj wouterj commented on an outdated diff Mar 30, 2013
components/http_foundation/introduction.rst
@@ -424,6 +426,26 @@ abstracts the hard work behind a simple API::
$response->headers->set('Content-Disposition', $d);
+.. versionadded:: 2.2
+ The :class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse` class was added in Symfony 2.2.
+
+Alternatively, if you are serving a static file, you can use a
+:class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse`::
+
+ use Symfony\Component\HttpFoundation\BinaryFileResponse
+
+ $file = 'path/to/file.txt';
+ $response = new BinaryFileResponse($file);
+
+The :class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse` will
@wouterj
wouterj Mar 30, 2013 Symfony member

There is no need to add 2 API links to the same page. I prefer to use the normal BinaryFileResponse inline code block here

@michaelperrin michaelperrin and 1 other commented on an outdated diff Mar 31, 2013
book/controller.rst
@@ -726,8 +726,12 @@ headers and content that's sent back to the client::
.. tip::
- There is also a special :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`
- class that helps return JSON responses. See :ref:`component-http-foundation-json-response`.
+ There are also special classes to make certain kinds of responses easier:
+
+ - For JSON, there is :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`.
+ See :ref:`component-http-foundation-json-response`.
+ - For files, there is :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`.
@michaelperrin
michaelperrin Mar 31, 2013

A little typo here: I think you meant Symfony\\Component\\HttpFoundation\\BinaryFileResponse

@jbafford
jbafford Mar 31, 2013

You're correct. I have that fixed now.

@weaverryan weaverryan merged commit 4140805 into symfony:2.2 Apr 4, 2013
@weaverryan
Member

Hey John!

This is really great - and I get to learn about a new feature from your work ;). I've only made a few small changes and also mentioned X-Sendfile at sha: 615a7b3. If you see any issues, let me know!

Thanks!

@jbafford
jbafford commented Apr 4, 2013

Glad to be of help! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment