FastRoute is a fast request router for PHP that uses regular expression based routing to match HTTP requests to handlers.
The library solves the problem of efficiently mapping incoming HTTP requests to the appropriate handler code. It works by accepting route definitions through a callback function, where routes are specified with HTTP methods, URI patterns using placeholder syntax like {id} or {id:[0-9]+}, and associated handlers. The router supports optional route segments in trailing positions, route grouping with common prefixes including nested groups, and optional caching of the compiled routing data to avoid recomputation on each request. When dispatching a URI, the router returns a status code indicating whether a match was found, the method was not allowed, or no route matched.
FastRoute suits projects that need reliable request routing in PHP applications where performance matters. The library is agnostic about how you interpret handlers—they can be callbacks, controller class names, or any other data you wish to associate with routes. The caching mechanism is particularly valuable for production deployments, allowing you to pre-compile routing tables and load them from cache rather than rebuilding them on each request. The tool requires PHP 8.1 or newer.
The project maintains a focused scope on routing performance and correctness. Development activity shows consistent attention to the core routing logic without scope creep into framework concerns like middleware or response handling. The codebase demonstrates careful consideration of edge cases, such as the explicit restriction on capturing groups within placeholders and the limitation of optional segments to trailing positions only. The library's design reflects a philosophy of doing one thing well—providing fast, predictable request routing—rather than attempting to be a full-featured framework.