symfony / symfony

The Symfony PHP framework
https://symfony.com
MIT License
29.81k stars 9.47k forks source link

[Routing][3.0] make use of PSR-7 #14723

Closed Tobion closed 7 years ago

Tobion commented 9 years ago

The routing component currently has two methods to match the request: UrlMatcherInterface and RequestMatcherInterface.

This sucks for implementations as people need to implement both and it is bad from an architecture perspective. It was only created as a workaround anyway. See also https://github.com/symfony-cmf/Routing/pull/116#issuecomment-68352907

For version 3.0 we should get rid of this. With the rise of PSR-7 it is also the perfect time to make use of these interfaces as well since we would break BC anyway. This of course requires https://github.com/symfony/psr-http-message-bridge so that the routing component can easily be integrated in symfony itself.

Here my vision:

Open questions:

Changing everything to URI would probably be too big of a BC break. So I guess we have to live with the URL vs URI inconsistency. I think matchRequest and generateUrl are better because they are more explicit. But that would require a BC break in UrlGeneratorInterface which we could avoid if we just leave it generate() (and match()).

Tobion commented 9 years ago

Performance impact of request transformation of was an argument in core meeting. So this would need to be measured.

stof commented 9 years ago

Do we really need to change the method name in UrlGeneratorInterface ?

Regarding keeping RequestMatcherInterface, an interface using PSr-7 must be a different interface, not the current RequestMatcherInterface, otherwise it is a big BC break.

Tobion commented 9 years ago

Regarding keeping RequestMatcherInterface, an interface using PSr-7 must be a different interface, not the current RequestMatcherInterface, otherwise it is a big BC break.

I think we need to discuss the goal of symfony 3 at next meeting. If the goal is that library authors can write code that is compatible with both symfony 2 and 3 at the same time, then we cannot do such a change indeed. How about PsrRequestMatcherInterface::matchPsrRequest? Looks ugly, but ok.

Do we really need to change the method name in UrlGeneratorInterface ?

No we do not need to as I explained. But then we keep the inconsistency generate vs matchPsrRequest.

nicolas-grekas commented 7 years ago

I think we can close here, to me, PSR-7 support is a very low priority and the benefit would be really thin.

javiereguiluz commented 7 years ago

I agree with Nicolas. Let's close. Thanks!

Gemorroj commented 5 years ago

@nicolas-grekas, @javiereguiluz In my case PSR-7 support would be useful for RoadRunner routing