In our attempt to convert parts of our own internal company framework into a set of open-source components we did not find a routing package that was fully PSR-7 compatible and was able to also generate uris based on the routing definitions. Initially the routing component was part of our Adroit middleware, a middleware focused on PSR-7 as well as the ADR pattern. During our attempt to turn Adroit into a (micro) web framework called Adrenaline we also extracted the routing component into a separate package.
Routes in Pathfinder are implemented immutable an can be built via the RouteBuilder helper:
Routes support so-called Matchers which can ensure that your route parameters match given criterias, e.g. checking that a given id contains only digits:
->ifMatches('userId', new NumericMatcher())
Last, but not least Pathfinder comes with middleware support. The routing middleware will use the given router to match the request and will set the routing result as value of the request attribute named 'routingResult'.
$router = new Psr7Router();
$routingMiddleware = new BasicRoutingMiddleware($router, 'routingResult');