Skip to main content

Announcing Pathfinder v0.4.0

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· 2 min read

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:

use bitExpert\Pathfinder\RouteBuilder;
use bitExpert\Pathfinder\Matcher\NumericMatcher;



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'.

use bitExpert\Pathfinder\Route;
use bitExpert\Pathfinder\Psr7Router;
use bitExpert\Pathfinder\Middleware\BasicRoutingMiddleware;

$router = new Psr7Router();

$routingMiddleware = new BasicRoutingMiddleware($router, 'routingResult');