-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Can't dispatch more than once on same RouteCollection #75
Comments
It's not something that is intended. Once documentation is written then it will include a section on this. What is your use case to dispatch twice? On Thu, Oct 8, 2015 at 10:02 PM, Bernardo notifications@github.com
|
My main use case at the moment is unit testing. I generate various requests Another use case could be internal routing to achieve something like HMVC (
|
Well the issue here is less the dispatch but the fact that the underlying router (FastRoute) does not allow matching twice so it's not something I can implement in the manner you describe. When it comes to unit tests, my personal opinion is that if you're routing, then it's not a unit test really, unit test the controller callable and let your other test suites look after routing or trust that the router is unit tested to ensure your routes will be matched. That being said, by using named routes you can achieve what you want to achieve by just pulling the route from the collection and dispatching the route directly. Handling it this way also has the benefit of not relying on paths, so they can change without having to then reactor where you're dispatching them from. On Thu, Oct 8, 2015 at 10:21 PM, Bernardo notifications@github.com
|
Fair enough, I'll try that. |
Too bad it's because of fastroute. Would be nice to use league/route in a reactphp powered application or something, where the router object is reused for every request |
You still can, but you'll have to build a wrapper around the dispatch method that creates a new |
Well, that's exactly what you would want to avoid :-) |
This is regarding the develop branch
When I try to dispatch more than once on the same
RouteCollection
instance, I get the following exception:If it's not intended to do so, this behaviour should probably be documented.
I can probably work around this with a factory of some sorts, but it would be neat if it was supported.
Minimal testcase:
The text was updated successfully, but these errors were encountered: