PHP-Router
PHP-Router copied to clipboard
Added shouldDispatchCallback
It is a very simple and naive implementation actually not PSR-15 compliant, but maybe it is a good start for PSR-15 compliance.
The idea is to set a callback before dispatching the route, with these rules :
- The callback take one parameter which is the Route to be dispatched
- if the callback returns false or equivalent, the route is ignored and the router continues to check other routes.
- if the callback returns a route, it is dispatched. So you can simply return the route to allow it, or generate a new Route in replacement (like an Error route for example).