-
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
route_to doesn't work for post routes #642
Comments
Well, damn, you're absolutely correct. Routing was one of the first items that was tackled, and the Any chance you want to make a PR for that? |
Sure. The only thing I can think of as a fix is to simply remove HTTPVerb check which as you alluded to, may impact performance slightly. |
Yup, that's exactly what I'd do. If we find it impacting performance we can refactor the matching process later. |
Kind of a silly question, but how do you normally get the tests to run locally? I tried running phpunit in the root directory and nothing happens. Need to write a few for this update. |
No worries. :) I install phpunit through Composer for this, since the Laravel projects I work on require different versions of phpunit. If it's installed that way, I always just do |
I figured out my issues with running the test which had to do some modification I made to the Constants.php file which included other package Constants. In thinking about this further, wont removing the HTTPVerb check potentially cause issues with GET/POST/DELETE routes with the same URI causing you to possibly get say the "DELETE" route when doing a "GET" request? Should we create a separate array that includes all created routes which the
Or by prefixing the route with the verb:
The latter 2 would probably be a bit more work to fix stuff. |
…with routes other then post
I think the way you did it works great. My initial concern was the resources taken up by the potentially empty arrays for the methods, since arrays used to be fairly expensive. I've seen some blog posts by Blackfire.io that show that these packed arrays are much cheaper in PHP 7. |
Actually, after thinking about this implementation more, we could potentially have an issue if a route with the same URI uses
I'm now thinking the string prefix approach may be better here. I'll work on it and send in a pull request for you to review. |
I got pretty far on the string prefix implementation but am having second thoughts now. The implementation I'm working on is giving me issues with named route lookups which are putting me down a smelly code alley that may not be worth it. The pull request array implementation just puts more importance on routes with a verb which may actually be better anyway. |
It seems to me that one with a specific method should normally override the wildcard version. Though, if someone waned to take the easy way and use |
I believe that scenario you describe would still work if you add the specific verb after the wildcard. It's when you add the wildcard after the verb that would be the issue if we are wanting the overall ordering of route declaration to determine which route is used. However, I'm feeling that if you specify a specific route over a wildcard, no matter what the order, that should be used (which should be what's happening now). |
Yeah, I agree. It should definitely check the specific verb collection first, and then check the wildcard grouping, and then fail. If that's what you've got, we should be good here, right? |
Fix for issue #642 regarding the route_to function and post routes
I have an issue where I have a form in which I want to set the action to the post route using the
route_to
function. However, because the context of calling thatroute_to
function is using theHTTPVerb
that's notpost
, it doesn't find the route because they are excluded from the route collection. This seems like a common use case for using route_to.Route Example:
The text was updated successfully, but these errors were encountered: