-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[DRAFT] 4.x Refactor Routing #2604
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bnf I would like your input on this when you get a minute. Thank you! |
This is in danger of being too big. Can we pull out some bits into their own PRs? |
2 tasks
2 tasks
This was referenced Apr 17, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft proposal to refactor all routing components as per issue #2583.
The proposed changes introduce the following interfaces:
RouteCollectorInterface
: Collects all routes and groups, handles cache fileRouteCollectorProxyInterface
: This interface is what theApp
components extends and also what is being passed intoRouteGroup
. We will not be exposing all ofApp
's methods when instantiating aRouteGroup
instead this proxy interface handles communication with theRouteCollector
RouteInterface
stays the same, minor change is that we have gotten rid ofRoutable
all togetherRouteGroupInterface
this interface now has acollectRoutes()
method which helps us get rid of the oldRouteGroup::__invoke()
,Router::pushGroup()
andRouter::popGroup()
methods.RouteCollectorProxy
has the ability to have a base path which will append it to all the patterns being passed via the proxy methodsget()
,put()
,post()
, etc. while collecting the routes from inside theRouteGroup
's callableRouteResolverInterface
this component is very simple and its only concerns are to create theFastRoute
dispatcher, dispatch theServerRequestInterface
to it and return the computedRoutingResults
via theRouteResolverInterface::computeRoutingResults()
method. This interface also has the responsibility to resolve the appropriate route communicating withRouteCollector
to achieve that.RoutingMiddleware
uses this resolver to perform the routing.Deprecated Components/Methods
Router
andRouterInterface
are now gone since they've been effectively separatedRoutable
does not exist anymore as it has been merged intoRoute
since it is the only component that was using those methodsRouteGroup
does not hold a$pattern
variable anymore as it is unnecessary due to the state of the pattern residing insideRouteCollectorProxy
when collecting the inner routes of a groupRoute::finalize()
does not exist anymore, it has effectively been merged withRoute::prepare()
RouteDispatcher
has been renamed toRouteRunner
since that's all it does, it callsRoute::run()
New Namespace Folder
![](https://camo.githubusercontent.com/83ea874632bac2c54cd99ec02aa21a0792c42181aa56c4035eb32ce78c7aa2c7/68747470733a2f2f7075752e73682f4355524c4c2f643035386263346266392e706e67)
New namespace folder called
Routing
which has all of the routing components.This PR will be separated into smaller ones
RouteGroup
&Route
fromRoutable
- 4.x Refactor RouteGroup & Route #2612 MergedRouter
intoRouteCollector
andRouteResolver
- 4.x - Split RouterInterface into RouteCollectorInterface and RouteResolverInterface #2622 MergedRoute::setInvocationStrategy()
toRouteInterface
- 4.x - Route InvocationStrategy Setter #2634 MergedRouteCollector::fullUrlFor()
as per Rewrite Router->urlFor() to generate complete Urls #2493 - 4.x - Port RouteCollector::fullUrlFor() #2638 MergedDispatcherInterface
to decouple from FastRoute Dispatcher - 4.x - Decouple FastRoute Dispatcher From RouteResolver #2639 MergedRouteParserInterface
to decouple from FastRoute RouteParser - 4.x - Decouple FastRoute RouteParser #2640 MergedRouteCollectorProxy
- 4.x - RouteCollectorProxy #2641 & 4.x - Refactor RouteCollectorProxy #2642 Merged