-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[3.0] [HttpFoundation] clean up/redesign Request class #6406
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@fabpot would you accept such an PR? |
FYI, |
Yes, I'm aware of that and this is definitely the reason why it was named this way. And I agree with you that since we deal with HTTP, not CGI, we should not do the same mistake. |
I agree with you but I'm -1 for changing this at this point. Probably something to be done for 3.0 |
Well, I changed by mind. The |
@Tobion - how about adding a new method |
the getUriForPath method is used qui frequently. So, again, let's do an overall in 3.0. |
I would love to see the public properties being hidden away in getters. This is already possible for 2.6 and easy to implement. The public properties could then be marked as deprecated and made private in 3.0. |
|
http://tools.ietf.org/html/rfc3875
So I think the the request class should have
The disadvantage is that people who don't want to ignore the script part (like routing) would need to call something like
|
PSR-7 looks good to me. So IMO Symfony 3.0 Request/Response should be based on that. |
Is there any specific work going on in that direction? I've recently ported our app (https://github.com/volkszaehler/volkszaehler.org) to HTTPKernelInterface (and ReactPHP...) and would like to understand where to go with this once PSR-7 is alive. |
@andig : that might depend on if we can get a PSR for HttpKernelInterface too. once PSR-7 is voted on, then hopefully we can move towards that. |
I make some profiling and realize that isSecure, getHost and so on methods usually return same result, because headers and server bags that is involved in results of this methods usually are not changed. And for now there is a lot of unnecessary calculations. Immutable request can help to avoid them. |
I would like to add that the constructors (if not using the factory methods) make it easy to create inconsistent representations. If I e.g. construct with If off-topic please ignore. |
There are several inconsistent method names and I think the class can be better designed.
setMethod
method which also modifies the ServerBag but there is nosetPath
. So either a Request should be immutable or mutable. But we have a mix of it. Furthermore, some getters a cached likegetPathInfo
and some are not likegetHost
. So when modifying the public parameter bags, sometimes it has influence on the Request getters and sometimes not. See also [HttpFoundation] Request::getPathInfo() inconsistencies #10478getUriForPath
is wrong. The correct name according to the current behavior would begetUriForPathInfo
getBaseUrl
andgetBasePath
are both unfortunate because the only difference is the inclusion of the script file name and has nothing to do with URL vs path.The method name forRequest::getPathInfo()
is so bad becauseSo the name is really confusing as it does not behave similar to phps pathinfo() and is also semantically wrong.
I suggest to deprecate
getPathInfo()
and introducegetPath()
.Working with it bothered me ever since. And I think we should fix that now before it's too late.
Changing some names like
baseUrl
(that also does not exist in CGI terms) will need to be reflected in the routing component as well.The text was updated successfully, but these errors were encountered: