Welcome to the InitPHP Router documentation. Every page is self-contained and built around runnable examples.
- Routing — HTTP verbs,
register(),add(),any() - Route parameters & patterns —
:typevs{name}, custom patterns, optional segments - Route groups — prefix, domain, port and client-IP grouping
- Controllers — handler formats and resource controllers
- Named routes & URLs — naming routes and generating URLs
- Dependency injection — handler arguments and PSR-11 containers
- Middleware — before/after filters
- Static file links — serving files and directories
- Error handling — 404 handling and exceptions
- Caching — caching the compiled route table
Throughout the docs, $router is an instance built like this:
use InitPHP\HTTP\Message\{Request, Response};
use InitPHP\Router\Router;
$router = new Router(Request::createFromGlobals(), new Response());Any PSR-7 request/response pair works; InitPHP HTTP is used here for concreteness.