Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[WIP] re-read of http-foundation component docs#2435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
a3ce7752d25c5e59f8e5badc045b8290eb978ece840338f966f9c74e66aad4a868815c6a5e3d920a75cbFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,7 +27,7 @@ You can install the component in many different ways: | ||
| Request | ||
| ------- | ||
| The most common way to createarequest is to base it on the current PHP global | ||
| variables with | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::createFromGlobals`:: | ||
| @@ -61,12 +61,12 @@ can be accessed via several public properties: | ||
| * ``attributes``: no equivalent - used by your app to store other data (see :ref:`below<component-foundation-attributes>`) | ||
| * ``files``: equivalent of ``$_FILES``; | ||
| * ``server``: equivalent of ``$_SERVER``; | ||
| * ``headers``: mostly equivalent to a sub-set of ``$_SERVER`` | ||
| (``$request->headers->get('user-agent')``). | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Both are correct IMO ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. You're right. Content-type could be used on a POST or PUT. Might I suggest that user-agent still could be a better choice since all requests are likely to have this. If someone is trying out code samples, they might be confused why content-type is coming up null. What do you think? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Both are good, so I'm cool with user agent. But I think we should have it be ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Ok, I will make the change. I'm also planning on picking this back up over the weekend to finish the WIP. Thanks for the feedback. | ||
| Each property is a :class:`Symfony\\Component\\HttpFoundation\\ParameterBag` | ||
| instance (or a sub-class of), which is a data holder class: | ||
| @@ -128,7 +128,7 @@ has some methods to filter the input values: | ||
| parameter value converted to integer; | ||
| * :method:`Symfony\\Component\\HttpFoundation\\ParameterBag::filter`: Filters the | ||
| parameter by using the PHP:phpfunction:`filter_var` function. | ||
| All getters takes up to three arguments: the first one is the parameter name | ||
| and the second one is the default value to return if the parameter does not | ||
| @@ -150,7 +150,7 @@ When PHP imports the request query, it handles request parameters like | ||
| ``foo[bar]=bar`` in a special way as it creates an array. So you can get the | ||
| ``foo`` parameter and you will get back an array with a ``bar`` element. But | ||
| sometimes, you might want to get the value for the "original" parameter name: | ||
| ``foo[bar]``. This is possible with all the ``ParameterBag`` getters like | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::get` via the third | ||
| argument:: | ||
| @@ -172,7 +172,8 @@ thanks to the public ``attributes`` property, which is also an instance of | ||
| :class:`Symfony\\Component\\HttpFoundation\\ParameterBag`. This is mostly used | ||
| to attach information that belongs to the Request and that needs to be | ||
| accessed from many different points in your application. For information | ||
| on how this is used in the Symfony2 framework, see | ||
| :ref:`the Symfony2 book<book-fundamentals-attributes>`. | ||
| Identifying a Request | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
| @@ -188,8 +189,8 @@ this is done via the "path info" of the request, which can be accessed via the | ||
| Simulating a Request | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
| Instead of creating arequest based on the PHP globals, you can also simulate | ||
| arequest:: | ||
| $request = Request::create( | ||
| '/hello-world', | ||
| @@ -198,9 +199,9 @@ a Request:: | ||
| ); | ||
| The :method:`Symfony\\Component\\HttpFoundation\\Request::create` method | ||
| creates a request based on aURI, a method and some parameters (the | ||
| query parameters or the request ones depending on the HTTP method); and of | ||
| course, youcan also override all other variables as well (by default, Symfony | ||
| creates sensible defaults for all the PHP global variables). | ||
| Based on such a request, you can override the PHP global variables via | ||
| @@ -210,19 +211,19 @@ Based on such a request, you can override the PHP global variables via | ||
| .. tip:: | ||
| You can also duplicate an existingrequest via | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::duplicate` or | ||
| change a bunch of parameters with a single call to | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::initialize`. | ||
| Accessing the Session | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
| If you have a session attached to therequest, you can access it via the | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::getSession` method; | ||
| the | ||
| :method:`Symfony\\Component\\HttpFoundation\\Request::hasPreviousSession` | ||
| method tells you if the request contains asession which was started in one of | ||
| the previous requests. | ||
| Accessing `Accept-*` Headers Data | ||
| @@ -238,13 +239,15 @@ by using the following methods: | ||
| returns the list of accepted languages ordered by descending quality; | ||
| * :method:`Symfony\\Component\\HttpFoundation\\Request::getCharsets`: | ||
| returns the list of accepted charsets ordered by descending quality. | ||
| Accessing other Data | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
| The ``Request`` class has many other methods that you can use to access the | ||
| request information. Have a look at | ||
| :class:`the Request API<Symfony\\Component\\HttpFoundation\\Request>` | ||
| for more information about them. | ||
| Response | ||
| -------- | ||