nikic/fast-route
FastRoute is a high-performance PHP 8.1+ request router using compiled regular expressions. Define routes with patterns and parameters (optional segments, constraints), dispatch by HTTP method and URI, and get NOT_FOUND, METHOD_NOT_ALLOWED, or FOUND with handler and vars.
This is a pre-release of FastRoute containing all recent improvements. It's meant for enabling downstream testing, specially the detection of unexpected BC-breaks.
In the meantime we'll be updating the documentation and dealing with any undesired breakage.
Check all changes in https://github.com/nikic/FastRoute/milestone/1?closed=1
RouteCollector properties protected instead of private.cacheDisabled option is enabled, the cache file is no longer written. Previously it was not read, but still written. (#114)get(), post(), put(), delete(), patch() and head() to the RouteCollector. (#109)Placeholder names may now start with an underscore (_) character.
This is a re-release of version 0.8.0 without code changes. Given the number of dependent projects there should be a formally stable release :)
* method and matched after all other routes.Added support for trailing optional segments, for example the route
$r->addRoute('GET', '/foo[/{bar}[/{baz}]]', 'handler');
is equivalent to the three routes
$r->addRoute('GET', '/foo', 'handler');
$r->addRoute('GET', '/foo/{bar}', 'handler');
$r->addRoute('GET', '/foo/{bar}/{baz}', 'handler');
As a result of this additional the output format for RouteParser was changed to add another array level, which may need to be accounted for if you use a custom parser.
routeCollector option to dispatcher functions. (#40)simpleDispatcher() and cachedDispatcher() functions will now only be defined if they do not yet exist, resolving some autoloading issues. (#39)This release changes the structure of the cached data (if cachedDispatcher is used), so the cache file should be removed after the update.
This release adds support for registering a route for multiple HTTP methods at the same time, by passing an array for the method parameter of RouteCollector::addRoute(). For example:
/** [@var](https://github.com/var) RouteCollector $r */
$r->addRoute(['GET', 'POST'], '/foo/{bar}', 'handlerForGetAndPost');
// This is equivalent to:
$r->addRoute('GET', '/foo/{bar}', 'handlerForGetAndPost');
$r->addRoute('POST', '/foo/{bar}', 'handlerForGetAndPost');
This release fixes a routing bug, which could occur if two non-disjoint routes for different HTTP methods are defined:
$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
$r->addRoute('GET', '/user/{name}', 'GET with default placeholder pattern');
$r->addRoute('POST', '/user/{name:[a-z]+}', 'POST with custom placeholder pattern');
});
A request to POST /user/foobar was previously rejected with 405 Method Not Supported and is now correctly matched.
For more information see #25.
This release changes the structure of the cached data (if cachedDispatcher is used), so the cache file should be removed after the update.
How can I help you explore Laravel packages today?