PHP-Router
PHP-Router copied to clipboard
Skip dispatch after match
- PHPRouter version: 1.2.0-alpha
- PHP version: PHP 7.1:
- Exact steps to cause this issue
- I configured RouteCollection
- I run method matchCurrentRequest on Router
- What you expected
- I expected to get all information about route and use this information in other middleware using psr 15
- What happened instead
- Router create controller object and run the action
Is it possible to turn of run method dispatch() after find route by configuration flag.
It would be great ! it reminds me a feature request here : #115 .
I have a private fork with a simple mecanism, i could make a pull request on this if owners change their minds.
@lpotherat please do it, send a PR.
PR made here #121 . It is a simple implementation that fit my needs, it may be enhanced.
As to avoid touching the lib and keeping it detached from the project and maintained via composer i have created this little wrapper to fit my functionality in a little dirty clever way so i can get the url in the middle of the request process instead of after the request process. A neat improvement would be to have ALL the request information available as a Router->getRequestInfo method or something like that.
Having it returned after the full request has been processed is nice and all, but is information you might need in the middle of the process more that at the end.
Here is my little code: https://gist.github.com/animalillo/e395beed4919a4325c8fdb26b7803e84
Another nice feature would be to set a base namespace for all the classes that run your routes and don't have to repeat the namespace for every route.