nikic/FastRoute ? reverse-engineered prompt
Reverse engineered prompt
Build me a small PHP routing library that can match HTTP requests quickly and cleanly.
I want to be able to define routes like GET, POST, PUT, PATCH, DELETE, and HEAD, with simple path placeholders like /user/{id:\d+}, optional trailing parts, and grouped routes with a shared prefix. Then it should take an HTTP method and a URI, figure out whether it is found, not found, or method not allowed, and return the matched handler plus any route variables.
It should also support a cached mode so the routing table can be built once and reused later. Keep the API easy to use from plain PHP, and make sure it works on PHP 8.1 or newer. If you need to check anything unclear, look up the current docs online first.
Are you gonna build this?
make sure you review the code using coderabbit